Here's another way... x <- c(2,2,4,6,2,4,4,6,8,6) match(x, unique(x))
Produces... [1] 1 1 2 3 1 2 2 3 4 3 On 12 August 2010 01:48, clips10 <m.mcquil...@lancaster.ac.uk> wrote: > > 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) and I want to create another vector which > is just numbers from 1 to 4 since there are only 4 unique numbers in my > vector, so for instance 2 would be 1, 4 would be 2, 6 would be 3, and 8 > would be 4, so my new vector would be ______________________________________________ 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.