[R] Getting the groupmean for each person
Gabor Grothendieck
ggrothendieck at myway.com
Sat May 8 23:02:40 CEST 2004
predict(lm(AV~as.factor(GROUP)))
Felix Eschenburg <Atropin75 <at> t-online.de> writes:
:
: Hello list !
:
: I have a huge data.frame with several variables observed on about 3000
: persons. For every person (row) there is variable called GROUP which indices
: the group the person belongs to. There is also another variable AV for each
: person. Now i want to create a new variable which holds the group mean of AV
: as a value for each person.
: With tapply(AV,GROUP,mean) i get the means for each level of GROUP, but i
: cannot find out, how to give every person the groupmean as a value (every
: person should have the same value as every other person in the same group).
:
: Has anybody any ideas how to do that ?
:
: Yours sincerly
: Felix Eschenburg
More information about the R-help
mailing list