I want to make my apply() function run parallel. I have loaded the parallel package and made a cluster. Then i have just changed the apply() function to the parApply() function. Unfortunately R doesn't seem to see the function parApply(). Help would be very appreciated.
Kind Regards, Jakub
My initial code:
- TRAITS and SNP are matrices
- the calling of apply() worked with no errors
library(parallel)
system.file(package='parallel')
detectCores()
copies_of_r <- 7
cl <- makeCluster(copies_of_r)
parApply(cl ,TRAITS,2,function(x) parApply(cl, SNP, 2, function(y) summary(lm(x~y))$coefficients[2,4]))
I got this:
> library(parallel)
> system.file(package='parallel')
[1] "C:/PROGRA~1/R/R-42~1.2/library/parallel"
> detectCores()
[1] 8
>
> copies_of_r <- 7
>
> cl <- makeCluster(copies_of_r)
>
> parApply(cl ,TRAITS,2,function(x) parApply(cl, SNP, 2, function(y) summary(lm(x~y))$coefficients[2,4]))
Error in checkForRemoteErrors(val) :
7 nodes produced errors; first error: nie udało się znaleźć funkcji* 'parApply'`
- "nie udało się znaleźć funkcji" == "failed to find funtion"
I also tried to call parApply() in this way:
parallel:: parApply(cl ,TRAITS,2,function(x) parApply(cl, SNP, 2, function(y) summary(lm(x~y))$coefficients[2,4]))
but I got the same result as before.
I also tried:
getAnywhere(parApply)
And suprisingly, R seems to see the function parApply() but has a problem, when I try to call it.
A single object matching ‘parApply’ was found
It was found in the following places
package:parallel
namespace:parallel
with value
(...)