You can pass a matrix to by()
set.seed(42)
dat <- data.frame(x=runif(50)*20, y=runif(50)*20,
g=rep(LETTERS[1:2], each=25))
as.vector(by(dat[,1:2], dat$g, function(x) cor(x)[1,2]))
[1] -0.05643063 0.16465040
-------------------------------------
David L Carlson
Associate Professor of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of Jannis
Sent: Thursday, June 27, 2013 12:27 PM
To: r-help
Subject: [R] multivariate version of aggregate
Dear List members,
i am seeking a multivariate version of aggregate. I want to compute,
fro
example the correlation between subsets of two vectors. In
aggregate, i
can only supply one vector with indices for subsets. Is there ready
function for this or do i need to program my own?
Cheers
Jannis