Skip to content
Prev 274582 / 398506 Next

question: ragged array

Hi:

Try this:

ratok <- data.frame(Id = rep(1:3, 3:1), value = c(2, 3, 4, 2, 1, 5))
aggregate(value ~ Id, data = ratok, FUN = mean)
  Id value
1  1   3.0
2  2   1.5
3  3   5.0

aggregate() returns a data frame with the Id variable and mean(value).

HTH,
Dennis

On Sun, Oct 16, 2011 at 6:53 AM, Helene Schreyer
<helene.schreyer at gmail.com> wrote: