I have some data as follows:
ASFR <- structure(list(age.group = c("15-19", "20-24", "25-29", "30-34","35-39", "40-44",
"45- 49","15-19", "20-24", "25-29", "30-34","35-39", "40-44","45-49"),
year=c(1917,1917,1917,1917,1917,1917,1917,1918,1918,1918,1918,1918,1918,1918),
asfr = c(0.18, 0.80,0.88, 0.69, 0.51, 0.23, 0.04, .18, .79, .87, .68, .50, .23, .04)), class
= "data.frame", row.names = c(NA, -14L))
I need to calculate TFR which is the sum of asfr column for each year from age 15 to 49. For instance, for the year 1917, it can be calculated as follows:
sum(ASFR[1:7,3])
Now, I need a new column whose name should be TFR in which each age- group be equal to TFR for that year. To illustrate more, I calculate two years in excel: