[R] Filter a matrix with a matrix HELP!

Cloneberry cloneberry at gmail.com
Thu Aug 2 15:16:32 CEST 2012


Hi,
just during these vacation days, I'm trying to approach with multicore
package
and I have some troubles with foreach.
What I'm trying to do is to extract a data in coordinate (ii,jj) from a
matrix2,
only if the data in the same coordinate in matrix1 is ==1.
Make this with a nested "for" take a lot of time because I have thousand of
values.

ex.
Binary_hex = NULL
foreach(ii=1:nrow(matrix2)) %:% foreach(jj=1:ncol(matrix2)) %dopar%
{when(matrix2[ii,jj] == 1) %:% {Binary_hex <- c(Binary_hex,
matrix1[ii,jj])}}

During this operation... computer don't work in multicore and the process
take a lot of time,
just like a simple nested for. I think the mistake is in the "when"
parameter because if I substitute
the "when" with another function (like "sqrt") it work greatly and fast.
Please, give me some suggestion, also with different way.
Thank you in advance.
Max



--
View this message in context: http://r.789695.n4.nabble.com/Filter-a-matrix-with-a-matrix-HELP-tp4638871.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list