[R] Recoding variable levels in R

Jonathan Baron baron at cattell.psych.upenn.edu
Mon Jan 7 14:48:00 CET 2002


>From: "Stuart Leask" <stuart.leask at nottingham.ac.uk>
>
>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

See recode() in the package called car

For other methods of recoding, see sections 4.4 and 4.5 of
http://www.psych.upenn.edu/~baron/rpsych.htm
(which is a bit out of date, but still true).

Jon Baron

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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