I have a data frame with a series of indicator variables whose responses determine the scoring of a second set of variables. What I have works, but it seems clunky.
Here's an example of what I've written:
ET.data$Q1_RUR <-NA
ET.data$Q1_RUR[Q1==1] <- 0.18831667304039
ET.data$Q1_RUR[Q1==2] <- -0.118123181164265
I'd like to be able to condense it down to a single line, sort of like you can do in Stata:
recode Q1 (1=0.18831667304039)(2=-0.118123181164265)(else=.),generate(Q1_RUR)
Any ideas on how I could further refine? Thanks!