Skip to content

aggregate

3 messages · Alaios, Petr Savicky, PIKAL Petr

#
On Wed, Mar 14, 2012 at 07:46:40AM -0700, Alaios wrote:
Hi.

Try the following.

  myData <- 1:100
  gr <- ceiling((1:length(myData))/30)
  c(tapply(myData, gr, FUN=mean))

     1    2    3    4 
  15.5 45.5 75.5 95.5 

Hope this helps.

Petr Savicky.
#
Hi
Why do you think so? Aggregate works on any suitable object, e.g. vector.
value.
by
a list of grouping elements, each as long as the variables in x.

the only thing what aggregate wants is

list(some.vector.with.the.same.length.as.variable.you.want.to.aggregate)

as some categorical data according to what you want to perform the 
function operation.

Regards
Petr
http://www.R-project.org/posting-guide.html