Or use the labels= argument of factor. On Sun, Jun 28, 2009 at 8:06 AM, Peter Dalgaard<p.dalga...@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.dalga...@biostat.ku.dk) FAX: (+45) 35327907 >
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.