An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20091111/0e32e061/attachment-0001.pl>
Removing levels of a factor
3 messages · Henrik Wahren, Dieter Menne, Uwe Ligges
Henrik Wahren wrote:
How can one or more levels be removed from a factor of a data frame. There was a similar post on how to do this when a factor meets some criterion (e.g. <= 2), but I can?t seem to get that solution to work. Here, I simply want to drop some levels.
Simply call factor again on the reduced set
a = factor(c("a","b","b","b"))
a[-1]
factor(a[-1])
If a is in a data frame, replace a by by df$a.
Dieter
View this message in context: http://old.nabble.com/Removing-levels-of-a-factor-tp26296742p26297130.html Sent from the R help mailing list archive at Nabble.com.
Dieter Menne wrote:
Henrik Wahren wrote:
How can one or more levels be removed from a factor of a data frame. There was a similar post on how to do this when a factor meets some criterion (e.g. <= 2), but I can?t seem to get that solution to work. Here, I simply want to drop some levels.
Simply call factor again on the reduced set
a = factor(c("a","b","b","b"))
a[-1]
factor(a[-1])
If a is in a data frame, replace a by by df$a.
or a[-1, drop=TRUE] Uwe Ligges
Dieter