[R] Recoding factors

Neil Leonard nleonard at tartarus.uwa.edu.au
Mon Oct 18 14:13:58 CEST 2004


Yes that's it.

Thanks
Neil

On 18/10/2004, at 7:57 PM, Prof Brian Ripley wrote:

> On Mon, 18 Oct 2004, Uwe Ligges wrote:
>
>> Neil Leonard wrote:
>>
>>> I'm having a bit of trouble recoding factors in a fields.
>>>
>>> I have a field which has the factors Singleton, Twin and Triplet.
>>> I want to recode the field to have only the factors Singleton and 
>>> Multiple.
>>>
>>> Any advice?
>>
>> Depends on what you are going to do with the Twin ...
>
> ?levels should help, though.
>
>> x <- factor(c("Singleton", "Twin", "Triplet"))
>> levels(x) <- c("Singleton", "Multiple", "Multiple")
>> x
> [1] Singleton Multiple  Multiple
> Levels: Singleton Multiple
>
> might be what is intended.
>
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>




More information about the R-help mailing list