I need to assign populations (denominators) to a data frame in R. For each age group and each year, the populations are different. My data frame is
Year agegroup count
2000 0-4 24
2000 5-9 36
....
2021 0-4 42
2021 95 132
How can I assign each year and age group (row) a different population?
I don't know how to do it, can someone help me? Thanks
CodePudding user response:
Thank you, I have this data frame:
head(pop) Year Age_group Count Population 1:00 1993 7 12
2:00 1994 7 18
3:00 1995 7 14
4:00 1993 8 16
5:00 1994 8 26
6:00 1995 8 27
7:00 1996 8 21
… Continue
And I want to put in the populations column the data that I have in another dataframe, so that the result is this:
head(pop1) Year Age_group Count Population 1:00 1993 7 12 133404 2:00 1994 7 18 155638 3:00 1995 7 14 100053 4:00 1993 8 16 211223 5:00 1994 8 26 111170 6:00 1995 8 27 255691 7:00 1996 8 21 255691
… Continue
CodePudding user response:
Sorry, I have this data frame: Year agegroup count 2000 0-4 24 2000 5-9 36 .... 2021 0-4 42 2021 95 132
And I want to put in the populations column the data that I have in another dataframe, so that the result is this:
Year agegroup count population 2000 0-4 24 123500 2000 5-9 36 132600 .... 2021 0-4 42 145200 2021 95 132 187540