[R] how to return indexes

Göran Broström gb at stat.umu.se
Thu Sep 5 13:00:07 CEST 2002


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
>
> Vincent

which(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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list