[R] Aggregate individual level data to age categories

stei@@@duke m@iii@g oii gm@ii@com stei@@@duke m@iii@g oii gm@ii@com
Wed Feb 12 21:39:42 CET 2020


Dear All,

I have a seemingly standard problem to which I somehow I do  not find
a simple solution. I have individual level data where x is a
categorical variable with 3 categories which I would like to aggregate
by age.

age x
45   1
45   2
46   1
47   3
47   3
 and so on.

It should after transformation look like that

age x_1 x_2 x_3
45    1     0   1
46    1     0   0
47     0    0   2

Basically to calculate prevalences by age categories.

Thanks for any pointers!

Cheers!



More information about the R-help mailing list