Skip to content
Back to formatted view

Raw Message

Message-ID: <CAD0a9KhxFnsem4HdKJn5MQFZS5Av+jN=ZZ0fAUYf18mMAKF-YQ@mail.gmail.com>
Date: 2018-08-21T18:15:08Z
From: Ariel Fuentesdi
Subject: parallelize distance matrix

Hi, I want to parallelize the calculation of a distance matrix, I've tried
but I wasn't succesful, this is what I did with a training data.

My data set is:

ll <- matrix(c(5, 6, 60, 60), ncol=2)

And I use the function *spDistsN1* from the library *"sp"* to obtain a
distance matrix with *apply*:

apply(ll, 1, function(x) spDistsN1(as.matrix(ll), x, longlat = T))

But I want to do it with parallelization, so for that:

library(parallel)
ncore <- detectCores()
cl <- makeCluster(ncore)
clusterEvalQ(cl = cl, expr = c(library(sp)))
parRapply(cl = cl, x = ll, FUN =  function(x) spDistsN1(as.matrix(ll), x,
longlat = T))

It shows the following error:

*Error in checkForRemoteErrors(val) : 4 nodes produced errors; first error:
object 'll' not found*

How do I fix it?
Regards,
Ariel Fuentes

	[[alternative HTML version deleted]]