FAQ
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.

--

Neil Davis
Ph.d.-student
DTU Wind Energy

Technical University of Denmark

Department of Wind Energy
Ris? Campus Frederiksborgvej 399, P.O. Box 49
Building 125
4000 Roskilde
Direct +45 46775067
neda at dtu.dk <mailto:neda@dtu.dk>
www.dtu.dk <http://www.dtu.dk>

## Search Discussions

•  at Apr 26, 2012 at 2:20 pm ⇧

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

## Related Discussions

Discussion Overview
 group r-help categories r posted Apr 26, '12 at 1:29p active Apr 26, '12 at 2:20p posts 2 users 2 website r-project.org irc #r

### 2 users in discussion

Content

People

Support

Translate

site design / logo © 2018 Grokbase