[R] Classification

smu ml at z107.de
Fri Nov 20 10:43:19 CET 2009


Hello,

x <- c(3,5,7,3,9,7)
> as.numeric(as.factor(x))
[1] 1 2 3 1 4 3

regards,
 stefan


On Fri, Nov 20, 2009 at 12:02:59AM -0800, Chris Li wrote:
> 
> Hi all,
> 
> I have got a dataset like the following:
> 
> 3
> 5
> 7
> 3
> 9
> 7
> 
> 
> i.e. random numbers with some repeats.
> 
> I want R to classify them for me. E.g. every row that has a value of 3 will
> be asigned a value of 1, and every row that has a value will be asigned a
> value of 2 etc.
> 
> I want R to return the following, using the example above:
> 
> 1
> 2
> 3
> 1
> 4
> 3
> 
> Thanks in advance.
> Chris
> -- 
> View this message in context: http://old.nabble.com/Classification-tp26429330p26429330.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list