by sapuser · 15y ago · 0 comments
# group by Species, can be multivalued see ?by
# sum(Sepal.Length, Sepal.Width)
# mean(Petal.Length, Petal.Width)
by(data = iris, INDICES = iris$Species, FUN = function(x) {y <- colSums(x[,c(1:2)]); z <- mean(x[,c(3:4)]); result <- list(y,z); result})No comments yet.