I have a dataset on population in states in the US from 2007-2019. However, it´s divided into age groups. I want to sum or aggregate the total population in the respective age groups so that I get one observation of the population for each state, each year.
Is there an easy way to do this?
structure(list(year = c("2007", "2007", "2007", "2007", "2007",
"2007"), GEOID = c("01", "01", "01", "01", "01", "01"), NAME = c("Alabama",
"Alabama", "Alabama", "Alabama", "Alabama", "Alabama"), variable = c("B01001_011",
"B01001_012", "B01001_013", "B01001_014", "B01001_015", "B01001_016"
), estimate = c(150937, 138364, 152306, 161670, 166578, 157116
), moe = c(2782, 2515, 5403, 5542, 2135, 2196)), row.names = c(NA,
-6L), class = c("tbl_df", "tbl", "data.frame"))