I am currently running numerous apply lines that look like this:
test=data.frame(t=seq(1,5,1),e=seq(6,10,1))
mean(apply(test,2,mean))
I want to convert the second line to mclapply which produces the same result as lapply. I realize that I could extract each item from the lapply statement using a for loop then use mean on that vector but that would slow down performance which I am trying to improve by using mclapply. The problem is both lapply and mcapply return a list which mean cannot use. I can either use [[]] to get the actual value or test$t and test$e but the number of columns in test is variable and typically runs over 1,000. There must be an easier way to handle this. Basically I want to get the mean of this statement:
mclapply(test,mean,mc.preschedule=TRUE)
preferably without generating new variables or using for loops. The solution should be equivalent to getting the mean of this statement:
lapply(test,mean)