Skip to content
Prev 326094 / 398503 Next

multivariate version of aggregate

Hi,
May be this also helps:
library(data.table)
dt1<- data.table(dat)
dt1[,cor(x,y),by=g]
#?? g????????? V1
#1: A -0.05643063
#2: B? 0.16465040
dt1[,cor(x,y),by=g]$V1
#[1] -0.05643063? 0.16465040

A.K.

----- Original Message -----
From: David Carlson <dcarlson at tamu.edu>
To: 'Jannis' <bt_jannis at yahoo.de>; 'r-help' <r-help at r-project.org>
Cc: 
Sent: Thursday, June 27, 2013 3:22 PM
Subject: Re: [R] multivariate version of aggregate

You can pass a matrix to by()
g=rep(LETTERS[1:2], each=25))
[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

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.