[R] Column-mean-values for targeted rows

2007-07-20 Thread Diogo Alagador
Hi all, I'm handling massive data.frames and matrices in R (3 x 400). In the 1st column, say, I have 0s and 1s indicating rows that matter; other columns have probability values. One simple task I would like to do would be to get the column mean values for signaled rows (the ones with 1)

Re: [R] Column-mean-values for targeted rows

2007-07-20 Thread Benilton Carvalho
set.seed(123) N = 3 K = 400 theData = matrix(rnorm(N*K), ncol=K) theData = as.data.frame(theData) theData = cbind(indicator = sample(0:1, N, rep=T), theData) system.time(results - colMeans(subset(theData, indicator == 1))) user system elapsed 2.309 1.319 3.853 b On Jul 20,