search for: 10010150

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

Did you mean: 10010100
2006 Jun 20
3
Create variables with common values for each group
...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(subset$h.age,na.rm=T),nrow(subset))) df$hhid: 10010020...