[R] Efficient cbind of elements from two lists
Stephan Dlugosz
stephan.dlugosz at googlemail.com
Thu Nov 19 16:03:13 CET 2009
Hi!
I have a data.frame "data" and splitted it.
data <- split(data, data[,1])
This is a quite slow procedure; and I do not want to do it again. So,
any unsplit and "resplit" is no option for me.
But: I have to cbind "variables" to the splitted data from another list,
that contains of vectors with matching sizes, so
for (i in 1:length(data)) {
data[[i]] <- cbind(data[[i]], l[[i]]))
}
works well; but very, very slowly.
The lapply solution:
data <- lapply(1:k, function(i) cbind(data[[i]], l[[i]]))
does not improve the situation, but allows for mclapply from the
multicore package...
Is there a more efficient way to combine elements from two lists?
Thank you very much!
Greetings,
Stephan
More information about the R-help
mailing list