[R] Aggregate function for comparison stats

David Winsemius dwinsemius at comcast.net
Thu Apr 26 16:20:19 CEST 2012


On Apr 26, 2012, at 9:29 AM, Neil Davis wrote:

> Hi,
>
> I have a data.frame which contains timeseries from several different  
> locations, which I want to compare against each other for example  
> calculating RMSE, or normalized mean bias of each location against  
> the others. An example of this is the cor function where I can put  
> in a data.frame and get the correlation of each location compared to  
> the others in the data.frame eg.
> cor(data.frame(a=runif(10),b=runif(10),c=runif(10),d=runif(10)))
>
> Is there any generic way of getting this for other functions, such  
> as the aggregate or lapply functions? I have read their  
> documentation, but was unclear as to how I might use them to get a  
> matrix like the cor function. I could do this using a pair of loops,  
> but was hoping there might be a more general way of creating such a  
> matrix of any comparison function.

Perhaps you are looking for:

?tapply

-- 
David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list