[R] Recode issue

Nikhil Kaza nkaza at unc.edu
Fri Oct 23 00:43:52 CEST 2009


I am having trouble with the recode function  that is provided in the  
CAR package. I trying to create a new factors based on existing factors.

E.g.

 >x <- as.factor(1:20)
 >y <- recode(x, " 1:5='A'; 6:10='B'; 11:15='C'; 16:20='D' ")
 >y

[1] A A A A A 6 7 8 9 A A A A A A A A A A A
Levels: 6 7 8 9 A

Could someone point to me, my error? Thanks




More information about the R-help mailing list