[R] transforming character categories
Gabor Grothendieck
ggrothendieck at gmail.com
Sun Jun 28 15:13:19 CEST 2009
Or use the labels= argument of factor.
On Sun, Jun 28, 2009 at 8:06 AM, Peter Dalgaard<p.dalgaard at biostat.ku.dk> wrote:
> Gabor Grothendieck wrote:
>>
>> If you only want to convert them to unique numbers then
>>
>> as.numeric(factor(x))
>>
>> will do that.
>
> Or, use it directly for indexing, as in c(1000,2500,4173,3700)[factor(x)]
>
> DEPENDING on LEVEL ORDER, mind you! So make sure you know what the order is
> or set it yourself using factor(x, levels=...)
>
> --
> O__ ---- Peter Dalgaard Øster Farimagsgade 5, Entr.B
> c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
> (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
>
More information about the R-help
mailing list