Hello, I wonder how to retreive indexes of data (and not data themseleves) example: a vector x<-c(10,20,30,40,50,60) a filter: f <- x>30 does retreive : 40,50,60 f <- x[x>30] retreive false,false,false,true,true,true i would retreive the indexes: 4,5,6 because the 4th, 5th and 6th values were selected (this easy with matlab, but with R I know only sort(..., index.return=TRUE) which does that thank you for help Vincent -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 5 Sep 2002, demolombe wrote:> Hello, > > I wonder how to retreive indexes of data (and not data themseleves) > > example: a vector x<-c(10,20,30,40,50,60) > a filter: f <- x>30 does retreive : 40,50,60 > f <- x[x>30] retreive > false,false,false,true,true,true > > i would retreive the indexes: 4,5,6 because the 4th, 5th and 6th values > were selected > > (this easy with matlab, but with R I know only sort(..., index.return=TRUE) > which does that >which() ?> x<-c(10,20,30,40,50,60) > f <- x[x>30] > f[1] 40 50 60> f <- which(x>30) > f[1] 4 5 6>Roger -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Breiviksveien 40, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93 e-mail: Roger.Bivand at nhh.no and: Department of Geography and Regional Development, University of Gdansk, al. Mar. J. Pilsudskiego 46, PL-81 378 Gdynia, Poland. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
On Thu, 5 Sep 2002, demolombe wrote:> Hello, > > I wonder how to retreive indexes of data (and not data themseleves) > > example: a vector x<-c(10,20,30,40,50,60) > a filter: f <- x>30 does retreive : 40,50,60 > f <- x[x>30] retreive > false,false,false,true,true,true > > i would retreive the indexes: 4,5,6 because the 4th, 5th and 6th values > were selected > > (this easy with matlab, but with R I know only sort(..., index.return=TRUE) > which does that > > thank you for help > > Vincentwhich(x > 30) --- G?ran Brostr?m tel: +46 90 786 5223 Department of Statistics fax: +46 90 786 6614 Ume? University http://www.stat.umu.se/egna/gb/ SE-90187 Ume?, Sweden e-mail: gb at stat.umu.se -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._