[R] Recoding variable levels in R

Stuart Leask stuart.leask at nottingham.ac.uk
Mon Jan 7 13:06:44 CET 2002


Hi there. When I wished to recode two variables in SPSS, I could use the
command RECODE:

recode VAR1 VAR2 VAR3 etc. (1=0) (2=1) (3,MISSING=SYSMIS) (else=0).

In R, I can 'hand-crank' each variable (using ifelse, or if the data is in a
matrix by logical tests, or no doubt numerous other methods) one variable
and one level at a time, but is there a more general function available?

Stuart

Dr Stuart Leask MA MRCPsych, Clinical Lecturer in Psychiatry
University of Nottingham Dept of Psychiatry, Duncan Macmillan House
Porchester Road, Nottingham. NG3 6AA. UK
http://www.nottingham.ac.uk/psychiatry/staff/sjl.html

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list