Skip to content

parallel rbind

5 messages · Steven Bauer, jim holtman, William Dunlap +1 more

#
As I am sitting here waiting for some R scripts to run...I was
wondering... is there any way to parallelize rbind in R?

I wait for this call to complete frequently as I deal with large
amounts of data.

do.call("rbind", LIST)
#
What exactly do you mean by "parallelize"?  What is wrong with the
approach that you are using now?  What is a "large amount of data"?
Can you give some specifics on the problem you are trying to solve and
why your present approach does not appear to be working?  What are
your expectations of a potential solution?
On Sun, Aug 28, 2011 at 8:36 PM, Steven Bauer <steven.bauer at gmail.com> wrote:

  
    
#
If you know much about what the elements of LIST look like
you can speed things up by not making R figure out what
you already know.  E.g., if you know that LIST consists of
p numeric vectors, all of the same length, n, then the following
might be faster
   matrix(unlist(LIST, use.names=FALSE), nrow=n)
If you are worried about row or column names then you can
add that information to the call to matrix().  (The above
will also work if LIST contains some matrix elements, as long as
they all have n rows.)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
#
Oops, I mixed up rbind and cbind.  If LIST consists
of n numeric vectors, each of length p, try
   matrix(unlilst(LIST, use.names=FALSE), nrow=n, byrow=TRUE)

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
#
Steven Bauer <steven.bauer <at> gmail.com> writes:
Perfectly reasonable question, but please don't cross-post
to StackOverflow and R-help -- pick one or the other.

  cheers
    Ben Bolker