Skip to content
Prev 323620 / 398503 Next

estimate value from simulations

Hello,

Try the following.

mat <- matrix(scan(text = "
  1 1 1 1 1 1
  2 2 2 2 2 2
  3 3 3 3 3 3
  5 5 5 5 5 5
  2 2 2 2 2 2
  3 3 3 3 3 3
  6 6 6 6 6 6
  2 2 2 2 2 2
  3 3 3 3 3 3
  1 1 1 1 1 1
  2 2 2 2 2 2
  3 3 3 3 3 3
"), ncol = 6, byrow = TRUE)

idx <- 1 + (seq_len(nrow(mat)) - 1) %% 3
aggregate(mat, list(idx), mean)


Hope this helps,

Rui Barradas

Em 16-05-2013 07:17, Zilefac Elvis escreveu: