[R] Subset: data frames and factor levels

Ben Bolker bolker at ufl.edu
Tue Apr 1 23:22:16 CEST 2008

Weidong Gu <wgu <at> uab.edu> writes:

> Try drop.levels in library gdata.

  For what it's worth, adding a drop.levels (default FALSE)
to subset is a long-standing wish of mine -- I keep meaning
to put together a patch to do this.  (This question comes
up about once a year on the R help list.)  I looked at the drop.levels
functionality in gdata (Warnes and Gorjanc are maintainers,
this code was written by Rogers and Gorjanc) -- I was hoping
it would be a simple drop-in, but although no piece of it
is very complicated there are a fair number of pieces
(generic definition, methods for data frame, factor, list,

   I think the best thing would be to (a) move this discussion
to R-devel (and/or e-mail with the authors of the stuff in
gdata) (b) put together a proposal for migrating drop.levels
into R base, along with a drop.levels= argument in subset:
I would argue that this would remedy a long-standing "infelicity".

  Ben Bolker

More information about the R-help mailing list