Hello, I have 2 variables in my sample Data: Data$A and Data$B Variable Data$A can assume values: 1, 2, 3, and 4. Variable Data$B identifies my cases and can assume values: 1 and 2.
I need to recode my variable Data$A into a new variable Data$new such that: People who are Data[Data$B %in% 1, ] are recoded like this: Value on Data$A Value on Data$new 1 +1 2 -1 3 0 4 99 People who are Data[Data$B %in% 2, ] are recoded like this: Value on Data$A Value on Data$new 1 -1 2 +1 3 0 4 99 I am having hard time doing this. Any help would be greatly appreciated. Dimitri ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.