Group by columns, then compute mean and sd of every other column in R
问题 How do I group by columns, then compute the mean and standard deviation of every other column in R? As an example, consider the famous Iris data set. I want to do something similar to grouping by species, then compute the mean and sd of the petal/sepal length/width measurements. I know that this has something to do with split-apply-combine, but I am not sure how to proceed from there. What I can come up with: require(plyr) x <- ddply(iris, .(Species), summarise, Sepal.Length.Mean = mean(Sepal