Der R-Gurus, first apologies if this is a FAQ, but I due to lack of R-knowledge and terminology I wasn't able to find it. I have the following problem in aggregating results of a model calculation: The results are yearly values of several parameters with several hierarchical spatial factors taken from a database as a data frame with the following structure
value | year | spatial1 | spatial2 | spatial3 | parameter the values are given for spatial1 units, i.e. the com spatial3 contains one or many spatial2 units, spatial2 contains one or many spatial1 units. The normal aggregation goes in a two step way: a) summation of the parameter values of the same spatial differentiaton (e.g. sums of spatial2 or spatial3) b) calculation of the average of several years of the sums for step a I use tapply with the following call indices <- (list(year,spatial2,parameter) resultspatial <- tapply(value,indices,sum) for step b I use apply with the result of a and a function block_average block_average <- funcition(value,year,number_of_years_to_average) with the parameters value and years as vectors and number_of_years as integer. When I'm trying to skip the spatial aggregation, i.e. just do the block_averaging over years, I have the problem (AFIU the man page), that I can't provide the years vector as parameter to the function block_average via tapply. What would be the R-ish approach to this problem. TIA joachim heidemeier -- Dr. Joachim Heidemeier c/o Umweltbundesamt FG II 2.2 Tel.: +49340 2103-2780 eMail: [EMAIL PROTECTED] [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.