[R] Creating vectors

Ben Bolker bbolker at gmail.com
Thu Aug 12 02:39:53 CEST 2010


clips10 <m.mcquillan <at> lancaster.ac.uk> writes:

> I didn't really know what to post as the topic subject, but I have a vector,
> for instance (2,2,4,6,2,4,4,6,8,6) [... snip to make gmane happy ...], 
> so my new vector would be (1,1,2,3,1,2,2,3,4,3).

x <- c(2,2,4,6,2,4,4,6,8,6)
as.numeric(factor(x))
 [1] 1 1 2 3 1 2 2 3 4 3



More information about the R-help mailing list