[R] Dataframe help

Erik Iverson iverson at biostat.wisc.edu
Wed Nov 5 17:46:38 CET 2008


Hello -

Rajasekaramya wrote:
> Hi there,
> 
> I have a dataframe length.unique.info
>> length.unique.info
> abc 12  345
> def  16  550
> lmn  6   600

Is this really the output when you print your data.frame?  You may have 
column names for columns 1, 2, and 3?  Is the first column a column of 
row.names, or not?  What does dim(length.unique.info) give?

Assuming you have names for columns "1", "2" and "3", named, e.g., X1, 
X2 and X3

subset(length.unique.info, X2 <= 5 & X3 >= 500, select = c(X1))

I don't know what you're trying to do by indexing with 'i'.

And to answer your question about '&', see ?Logic


> I want those names that fall under the condition (length.unique.info[,2][i]
> <=5 && length.unique.info[,3][i] >=500)
> 
> abcder<-length.unique.info[which(length.unique.info[,2][i] <=5 &&
> length.unique.info[,3][i] >= 500),1]
> 
> will "&&" look for both the condition.It isnt returning names is there
> anything i am missing.Kindly suggest me the way to do it.
> 
> Regards
> Ramya
> 
> 
>



More information about the R-help mailing list