[R] Numeric to factor

Göran Broström gb at stat.umu.se
Tue Oct 8 21:41:30 CEST 2002


I find 'How do I convert factors to numeric?' in the FAQ (7.12), but not
the other way around. Trivial maybe, but

> codes(factor(c(2, 10))
[1] 2 1
> codes(factor(c(2, 9)))
[1] 1 2

How do I get the levels attached to the codes in numeric order?

Göran
---
 Göran Broström                    tel: +46 90 786 5223
 Department of Statistics          fax: +46 90 786 6614
 Umeå University                   http://www.stat.umu.se/egna/gb/
 SE-90187 Umeå, Sweden             e-mail: gb at stat.umu.se


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list