[R] Dataframe help

Oliver Bandel oliver at first.in-berlin.de
Sun Dec 21 16:43:40 CET 2008

Rajasekaramya <ramya.victory <at> gmail.com> writes:

> Hi there,
> I have a dataframe length.unique.info
> > length.unique.info
> abc 12  345
> def  16  550
> lmn  6   600
> I want those names that fall under the condition (length.unique.info[,2][i]
> <=5 && length.unique.info[,3][i] >=500)


late answer, but I just looked in the archive...
...and found your question.

Maybe it's too long ago, but as I has some time for and fun with it,
here a way how to achieve it:

intersect( which(mydf[,2] <=5 ), which( mydf[,3] >= 500))

This will result in integer(0), which means, no matching data found.

intersect( which(mydf[,2] <=8 ), which( mydf[,3] >= 500))
would bring you 3 as an answer.
This is the index 3, which means third row does match.

So, you dont need a loop, which I assume you would like to use,
when using i as an index (maybe in the range 1:nrow(length.unique.info).


More information about the R-help mailing list