X <- c(1:9)
data <- data.frame(x)
I want a table where I get three numbers: mean(of first three) mean(of next three) mean(of last three)
X <- c(1:9)
data <- data.frame(x)
I want a table where I get three numbers: mean(of first three) mean(of next three) mean(of last three)
You need to create a new variable that will be used as a group. Here's an example:
> data$group <- rep(c("a", "b", "c"), each = 3)
> aggregate(X ~ group, data = data, FUN = mean)
group X
1 a 2
2 b 5
3 c 8