-1
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)

Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197

1 Answers1

0

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
Roman Luštrik
  • 69,533
  • 24
  • 154
  • 197