[R] row indexes from logical statment

Ista Zahn istazahn at gmail.com
Thu Feb 18 17:32:45 CET 2010


Hi Stephen,
See below.

On Thursday 18 February 2010 11:01:25 am stephen sefick wrote:
> Is there any easy way to pull out the row indexes for a logical
> matching statment?
> 
> #################example 
code#########################################
> foo <- data.frame(name=c(rep("A", 25), rep("B", 25), rep("C", 25),
> rep("A", 25)), stuff=rnorm(100), and=rnorm(100), things=rnorm(100))
> 
> #this is what I want but I would like the row indexes
> foo[foo[,1]==A,]
>

row.names(foo[foo[,1]=="A",])

 ######################################################################
> 
> Also, is there a way to get both A or B into the logical statment

?"|"

Best,
Ista

> 
> thanks so much for all of your help
> 
> Stephen



More information about the R-help mailing list