I have a list with 160 dataframes, that all have the same structure. Every dataframe corresponds to one country
Afghanistan <- data.frame(seq(1970, 2010, 10), c(20,30,30,40,10))
Albania <- data.frame(seq(1970, 2010, 10), c(10, 40, NA, 50, 20))
colnames(Afghanistan) <- (c("Year", "Value"))
colnames(Albania) <- (c("Year", "Value"))
List1 <- list(Afghanistan, Albania)
Every Dataframe's structure looks like this:
Year Value
1970 20
1980 30
1990 30
2000 40
2010 10
How can I get the mean of the column "Value" for each dataframe in the list. I tried to use the lapply function, but I couldn't figure out how to do it correctly. This didn't work:
lapply(List1[[]][,2], mean, na.rm = T)
Or would it be better to union all dataframes to one single big dataframe and then use aggregate to get the mean for every country?