right now I have a vector of about 1000 points. I'd like to iterate through each of these points and and test if it is greater than a certain value and if not, throw it out. x=vector y=empty vector j=0 for i (0..length[vector]) if x[i] > 10 y[j] = x[i] j++ Thats basically some pseudo code of what I want to do. Any suggestions? -- View this message in context: http://www.nabble.com/if-statement-of-a-vector-tp22166108p22166108.html Sent from the R help mailing list archive at Nabble.com.
Hi there, Try this: x<-your.vector x[x>10] HTH, Jorge On Mon, Feb 23, 2009 at 12:31 PM, bioinformatics_guy <wwwhitener@gmail.com>wrote:> > right now I have a vector of about 1000 points. I'd like to iterate through > each of these points and and test if it is greater than a certain value and > if not, throw it out. > > x=vector > y=empty vector > j=0 > > for i (0..length[vector]) > if x[i] > 10 > y[j] = x[i] > j++ > > Thats basically some pseudo code of what I want to do. Any suggestions? > > > -- > View this message in context: > http://www.nabble.com/if-statement-of-a-vector-tp22166108p22166108.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]
Hi r-help-bounces at r-project.org napsal dne 23.02.2009 18:31:32:> > right now I have a vector of about 1000 points. I'd like to iteratethrough> each of these points and and test if it is greater than a certain valueand> if not, throw it out. > > x=vector > y=empty vector > j=0 > > for i (0..length[vector]) > if x[i] > 10 > y[j] = x[i] > j++This Is R not C. y <- x[x>10] I recommend you to have a look into the R intro where you can find some quite basic manipulations with objects. Regards Petr> > Thats basically some pseudo code of what I want to do. Any suggestions? > > > -- > View this message in context:http://www.nabble.com/if-statement-of-a-vector-> tp22166108p22166108.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code.