[R] drop levels problem

Joshua Wiley jwiley.psych at gmail.com
Mon Nov 29 20:31:19 CET 2010

Just to follow up on my own post a bit:

xmelt$year[xmelt$year == "first", drop = TRUE]

will do what you want.  I think because in the subset there are
multiple columns not all of which are factor, the method for '[' being
used is not the factor one that would drop unused levels.  I did not
make that clear at all the first time around (and probably still
butchered it, which some knowledgeable soul may correct me on).  Also
I did get Hmisc installed, but I think dropUnusedLevels() does not
work in this case for a similar reason.

Henrique's solution is, as usual, the shortest :)



More information about the R-help mailing list