How to call global function speedDistribution
from the parLapply
function?
speedDistribution <- function(speed)
{
return(quantile(speed, seq(0.2, 1, by = 0.20)))
}
estimateFeatures <- function(trips,target)
{
cl <- makeCluster( 4 )
features = NULL
features = parLapply(cl, 1:length(trips), function(z){
z <- as.data.frame(z)
speed <- 3.6 * sqrt(diff(z$x)^2 + diff(z$y)^2)
s <- speed[!speed > mean(speed) + sd(speed) * 5]
features = c(speedDistribution(s),target)
return(cbind(features, rep(z, nrow(features))))
})
stopCluster(cl)
return(features)
}
Error in checkForRemoteErrors(val) : 4 nodes produced errors; first error: could not find function "speedDistribution"