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."
S
I need advice on how to create a variable that is the group mean of
another variable.
For example, I have a variable called x for which each row in the data
set has a value. I also have a nominal variable called g that
indicates which of 100 different groups each row belongs to.
So, I want to cre
I used the following to assign each row the group average, where w is
the new group average variable, x is the variabale to be averaged, and
g is the nominal group indicator:
w <- ave(x,g)
Now I want to calculate the group average, but WITHOUT each row's
value of x. Is there an easy way to do thi
3 matches
Mail list logo