Skip to content
Prev 326106 / 398506 Next

multivariate version of aggregate

Yes, I had a look at that function. From the documentation, however, it 
did not get clear to me how to split the dataframe into subsets of rows 
based on an index argument. Like:


testframe <- data.frame(a=rnorm(100), b = rnorm(100))
indices      <- rep(c(1,2), each = 50)


results <- ddply(.data = testframe, INDICES= indices, .fun = function(x) 
corr(x[,1], x[,2]))

Where the last command would yield the correlations between column 1 and 
2 of the first 50 and of the last 50 values.

Any ideas?

Jannis
On 27.06.2013 21:43, Greg Snow wrote: