Re: [R] correlation between rows of data.frame

2008-08-02 Thread jim holtman
You can convert to a numeric matrix to make the operations faster: > > x=data.frame(id=rep(sample(1:10,size=1),2),a=sample(c(NA,rnorm(10,0,1)),size=2, + replace=T),b=sample(c(NA,rnorm(10,0,1)),size=2, + replace=T),c=sample(c(NA,rnorm(10,0,1)),size=2, replace=T)) > x$id=factor

Re: [R] correlation between rows of data.frame

2008-08-01 Thread Christos Hatzis
Eleni, A way to do this is to group the data first using 'split' and then sapply the dist function to this list. The slower step will be the split which took a couple of minutes on my laptop but sapply should not take more than a minute or so. size <- 1 df <- data.frame( id=rep(sample