[R] Noob question - Identity argument within aggregate function?

David Winsemius dwinsemius at comcast.net
Fri Mar 2 23:38:01 CET 2012

On Mar 2, 2012, at 3:51 PM, knavero wrote:

>> aggregate(z, identity, mean)
>  1   2   3   4   5
> 1.0 3.0 5.0 6.0 7.5
>> aggregate(z, mean)
> Error: length(time(x)) == length(by[[1]]) is not TRUE

As generally happens when you call a function and fail to provide  
enough arguments to fill up its formals list.

> Can someone help me understand the error above and why "identity" is
> necessary to satisfy the error

Well on my machine it throws an error, probably because you failed to  
provide the requested code to create the objects you were working on.  
Is 'z' so sort of special classed object for which there is an  
aggregate method? Is 'identity' a list as expected by  
aggregate.default or aggregate.data.frame? It would be an unfortunate  
choice of an object name, since there is a function with that nam.

David Winsemius, MD
West Hartford, CT

More information about the R-help mailing list