[R] subsetting by cell value with a list
Petr Savicky
savicky at cs.cas.cz
Thu Mar 15 22:00:09 CET 2012
On Thu, Mar 15, 2012 at 03:47:24PM -0500, G See wrote:
> On second thought, I must not understand your question because your
> code works fine for me.
>
> > my.df[ which(my.df$IDX == c(17, 42)), ]
> IDX x
> 17 17 -0.5110095
> 42 42 -1.0686427
Hi.
This seems to work due to the fact that 17 is odd
and 42 is even, so they appear at the right place
in recycling c(17, 42).
IDX <- 1:50
which(IDX == c(17, 42))
[1] 17 42
which(IDX == c(18, 42))
[1] 42
which(IDX == c(18, 43))
integer(0)
Petr Savicky.
More information about the R-help
mailing list