Skip to content
Prev 176219 / 398513 Next

Grouping of data frames to calculate means

On Mon, 6 Apr 2009, Steve Murray wrote:

            
Put all the tables in a list, then you can iterate over them, eg
  lapply(the_list, function(table) mean(table[,3))

You might also want a list of lists to maintain the annual structure, so 
that

januaries <- lapply(list_list, function(year) mean(year[[1]][,3]))

 	-thomas
Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle