Re: [R] Building a big.matrix using foreach

2009-07-20 Thread Michael Knudsen
On Sun, Jul 19, 2009 at 2:29 PM, Jay Emersonjayemer...@gmail.com wrote: Hi Jay! foreach(i=1:nrow(x),.combine=c) %dopar% f(x[i,]) That was also my first guess, but it doesn't seem to work. Here is a trivial example using a regular matrix instead of a big.matrix. The outcome is the same. m =

Re: [R] Building a big.matrix using foreach

2009-07-20 Thread Michael Knudsen
On Sun, Jul 19, 2009 at 4:02 PM, Michael Kanekaneplusp...@gmail.com wrote: Hi Mike, desc = describe(x) foreach (i=1:nrow(x), .combine=c, .packages='bigmemory') %dopar% {   x = attach.big.matrix(desc)   f(x[i,]) } Thanks! The shared.big.matrix was exactly what I needed. It still remains

Re: [R] Building a big.matrix using foreach

2009-07-20 Thread Michael Knudsen
On Mon, Jul 20, 2009 at 10:23 AM, Michael Knudsenmicknud...@gmail.com wrote: Thanks! The shared.big.matrix was exactly what I needed. It still remains for me, though, to check if I run into memory problems anyway. It doesn't seem as if there's a don't return anything option in the foreach

Re: [R] Building a big.matrix using foreach

2009-07-19 Thread Jay Emerson
Michael, If you have a big.matrix, you just want to iterate over the rows. I'm not in R and am just making this up on the fly (from a bar in Beijing, if you believe that): foreach(i=1:nrow(x),.combine=c) %dopar% f(x[i,]) should work, essentially applying the functin f() to the rows of x? But

Re: [R] Building a big.matrix using foreach

2009-07-19 Thread Michael Kane
Another thing to realize if you are doing this in parallel, f(x[i,]) is being executed on each of the worker R sessions. Now, a big.matrix object is essentially a pointer to an object created in C++ and, a pointer address space is specific to a process (in this case the master R session). As a

[R] Building a big.matrix using foreach

2009-07-18 Thread Michael Knudsen
Hi there! I have become a big fan of the 'foreach' package allowing me to do a lot of stuff in parallel. For example, evaluating the function f on all elements in a vector x is easily accomplished: foreach(i=1:length(x),.combine=c) %dopar% f(x[i]) Here the .combine=c option tells foreach to