search for: w9zd9_3

Displaying 1 result from an estimated 1 matches for "w9zd9_3".

Did you mean: w9zd9_1
2009 Sep 14
2
how to recode with an if-type statement
I'm sure this is easy, but I'm having a hard time figuring out how to recode some data in R. I have a variable "numpeers" which is valued 1, 2, or 3. I also have three other variables called "w9zd9_1," "w9zd9_2," and "w9zd9_3." I want to use these variables to create a new item called "distot." Specifically, here is what I want to do: -if numpeers=1, then distot=w9zd9_1 -if numpeers=2, then distot=(w9zd9_1 + w9zd9_2)/2 -if numpeers=3, then distot=(w9zd9_1 + w9zd9_2 + w9zd9_3)/3 Thanks, in advance, fo...