s-news
[Top] [All Lists]

Re: Removing levels from a factor

To: s-news@lists.biostat.wustl.edu
Subject: Re: Removing levels from a factor
From: Gregor Gorjanc <gregor.gorjanc@bfro.uni-lj.si>
Date: Thu, 20 Mar 2008 20:04:51 +0000 (UTC)
References: <A413DCB0A7390F41B86A3EF6E2C9743A37BDAC6C69@usto-pmsg-mbs02.am.corp.amgen.com> <47CEE95B.9010202@vanderbilt.edu> <40e66e0b0803151330i3a6f658dn6d0d33eb07edc87b@mail.gmail.com>
User-agent: Loom/3.14 (http://gmane.org/)
Douglas Bates <bates <at> stat.wisc.edu> writes:
...
> 
> However, as far as I can tell no one answered the original question
> which was how do you drop unused levels from a factor - assuming that
> you do not want to do this by banishing the concept of a factor and
> exiling any person who dares to speak the name. The answer in R, and I
> believe also in S-PLUS, is to use drop = TRUE in a subscripting
> expression.  Thus

There is also drop.levels() function in gdata package for R - I am not
sure if it is also in S-PLUS port. I use it often. Usually I import the
data, check the structure with str(), occasionally I remove some data
and then unused levels come up. Use of drop.levels() after data handling
saved me a lot of "problems" later on.

Gregor




<Prev in Thread] Current Thread [Next in Thread>