Re: [R] re-coding variables

From: Christos Hatzis <christos_at_nuverabio.com>
Date: Fri 03 Feb 2006 - 03:29:29 EST


Look at function recode() in library("car").

-Christos

-----Original Message-----
From: r-help-bounces@stat.math.ethz.ch
[mailto:r-help-bounces@stat.math.ethz.ch] On Behalf Of Marc Bernard Sent: Thursday, February 02, 2006 11:12 AM To: r-help@stat.math.ethz.ch
Subject: [R] re-coding variables

Dear All,    

  I wonder how to re-code a categorical variable without using the ifelse loops. For example:
  Let X be a categorical variable with 6 levels, levels(X) = c(1,2,3,4,5,6)    

  How to create a new categorical variable Y with levels, 10,11,12, say , such that:

  Y = 10 if X =1 or X=2
  Y = 11 if X =3 or 4
  Y =11 if X = 5 or 6
   

  many thanks,    

  Bernard                     


        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html

R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Feb 03 03:42:55 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Feb 2006 - 15:12:02 EST