[R] Subset doesn't drop unused factor levels
sundar.dorai-raj at PDF.COM
Thu Oct 7 20:00:59 CEST 2004
hadley wickham wrote:
> a <- data.frame(b = rep(1:5, each=2), c=factor(rep("a",10), levels=c("a","b")))
> levels(subset(a, b=1, drop=T)$c)
> #  "a" "b"
> Is this a bug?
No, drop = TRUE is not doing what you're thinking it's doing. From
The 'drop' argument is passed on to the indexing method for data
I think you're hoping it is passed on to the indexing method for
factors, which it isn't.
More information about the R-help