I am looking to create a new data frame of averages based off a population data frame. Column A is a list of ages followed by the population of each for a number of years. I am wondering what the best approach to creating a new data frame with the average age for each year. The formula I am using to calculate the average is sum(age*year)/sum(year)
For example this is what I have:
Age | 2000 | 2001 | 2002
------------------------
2 | 4 | 1 | 2
3 | 6 | 3 | 5
4 | 10 | 9 | 8
and I would like a new data frame like this:
Year| Avg_age
--------------
2000 | 3.3
2001 | 3.6
2002 | 3.4