Skip to content
Prev 51166 / 398500 Next

subset(..., drop=TRUE) doesn't seem to work.

Hello!

If I read ?subset, the workings of the argument drop (to me) seem to imply 
equivalence of A and B (R 1.9.0):

#A
dd <- data.frame(rt=rnorm(10), c=factor(gl(2,5)))
dd <- subset(dd, c==1)
dd$c <- dd$c[, drop=TRUE]
table(dd$c)

1
5
	

#B
dd <- data.frame(rt=rnorm(10), c=factor(gl(2,5)))
dd <- subset(dd, c==1, drop=TRUE)
table(dd$c)

1 2
5 0

So to lose the second level of dd$c, in method B I still need to 'dd$c <- 
dd$c[, drop=TRUE]', while the manual seems to imply that with the drop 
argument to subset() this would not be necessary.


Could you comment?

kind regards,
Paul