On Sep 1, 2011, at 21:11 , R. Michael Weylandt wrote: > Dropping all occurences of a factor does not drop that level. This actually > turns out to be much more useful than it first might appear, but if you > really need to get around it, it can be done.
...most expediently by using factor(), as others have pointed out. Or droplevels() for data frames. We had the converse issue just the other day (Aug 30) when someone had problems with "showing zero frequencies in xtabs", which turned out to be caused by the tabulated data _not_ being factors, hence not containing information about which values could have been there but wasn't. The behavior of subsetting operators is so as to make things like tables and barplots consistent across subsets, but there are cases where you want the extra levels dropped. However, the default is as it is, because it is easier to drop levels than to reinstate them. Neither is impossible, of course. -- Peter Dalgaard, Professor, Center for Statistics, Copenhagen Business School Solbjerg Plads 3, 2000 Frederiksberg, Denmark Phone: (+45)38153501 Email: pd....@cbs.dk Priv: pda...@gmail.com "Døden skal tape!" --- Nordahl Grieg ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.