I have the following data:
a <- c(1,1,1,1,2,2,2,2)
b <- c(2,4,6,8,2,3,4,1)
c <- factor(c(\"A\",\"B\",\"A\",\"B\",\"A\",\"B\",\"A\",\"B\"))
df <- data
The library plyr is very helpful for stuff like this
library(plyr)
new.df <- ddply(df, c("method", "sp"), summarise,
mean.length=mean(length),
max.length=max(length),
n.obs=length(length))
gives you
> new.df
method sp mean.length max.length n.obs
1 A 1 4 6 2
2 A 2 3 4 2
3 B 1 6 8 2
4 B 2 2 3 2
More examples at http://www.inside-r.org/packages/cran/plyr/docs/ddply.