Displaying 1 result from an estimated 1 matches for "10010142".
2006 Jun 20
3
Create variables with common values for each group
...nd just couldn't find a solution.
The problem is to create new variables from a data frame which
contains both individual and group variables, such as mean age for an
household. My data frame:
df
hhid h.age
1 10010020 23
2 10010020 23
3 10010126 42
4 10010126 60
5 10010142 20
6 10010142 49
7 10010142 52
8 10010150 18
9 10010150 51
10 10010150 28
where hhid is the same number for each household, h.age the age for
each household member.
I tried tapply, by(), and aggregate. The best I could get was:
by(df, df$hhid, function(subset) rep(mean(su...