[R] Recoding Variables in R

Mathew, Abraham T amathew at ku.edu
Thu Jan 28 16:14:38 CET 2010


 

VAR 980490 

Some people have suggested placing new limits on foreign

imports in order to protect American jobs. Others say

that such limits would raise consumer prices and hurt

American exports.

Do you FAVOR or OPPOSE placing new limits on imports, or

haven't you thought much about this?

1. Favor

5. Oppose

8. DK

9. NA; RF

0. Haven't thought much about this

 

 

I am trying to recode the data for the following public opinion question from the ANES. I would like to throw out 8 and 9. Furthermore, I would like to reorder the responses so that:

1. Oppose (originally 5)

2. Haven't though much about this (originally 0)

3. favor (originally 1)

 

I tried the following, which did not work:

library(car)
data96$V961327 <- recode(data96$V961327, "c(1)=2; c(2)=3; c(3)=1")

 

 

I also tried the following, which also did not work:

new <- as.numeric(data96$V961327)
new
data96$V961327 <- recode(new, "c(5)=1; c(0)=2; c(1)=3")

 

 

 

Help,

Abraham M

 



More information about the R-help mailing list