Skip to content
Back to formatted view

Raw Message

Message-ID: <1AFE4EA7-F1C0-4426-A0D3-9DB5BFC3CFB2@comcast.net>
Date: 2013-07-24T18:47:57Z
From: David Winsemius
Subject: Levels of a factor
In-Reply-To: <88ED1074-4C48-4BC2-A493-B94B7DAD3889@comcast.net>

On Jul 24, 2013, at 11:35 AM, David Winsemius wrote:

> 
> On Jul 24, 2013, at 6:25 AM, Borja Rivier wrote:
> 
>> Hi all,
>> 
>> I am having a bit of trouble using the levels() function.
>> I have a factor with many elements, and when I use the function levels() to
>> extract the list of unique elements, some of the elements returned are not
>> actually in the factor.
>> 
>> snipped
> 
> When you take a subset of a factor vector, the levels are not reduced to the unique values in the new vector. There is droplevels function that would need to be applied if you already have such a vector, and there is a drop argument that you need to set to TRUE in the `[.factors`

Make that `[.factor`

> call if you want to "attack the problem at the source".
> 
> ?`[.factor  # missing trailing back-tick

?`[.factor`


> ?droplevels
> 
> -- 

David Winsemius
Alameda, CA, USA