[R] Apply Function to List by Group Returning Result with Dim of List

jamesrobinsonjnr jamesrobinsonjnr at gmail.com
Fri Jan 20 00:42:08 CET 2012


I have a panel data set defined as a simple data.frame with a factor age and
income. I would like to generate the results of a set function such as (sum,
mean, or even diff) separate for each factor (category or age group).
However I want the result to have the same dimension as the overal
data.frame. Therefore, I expect to get repeaded the same result for each
item within a category, but different accross categories. 

Eg:
age    income    avg_inc
20         100           100
20           90           100  
20         110           100
30          200          200
30          250          200
30          150          200

What builtin function can assist in doing this without my having to write
loops. I know in Eviews there is the sumsby, meansby, minsby and so forth.

--
View this message in context: http://r.789695.n4.nabble.com/Apply-Function-to-List-by-Group-Returning-Result-with-Dim-of-List-tp4311880p4311880.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list