'Error in checkForRemoteErrors(val) : one node produced an error: argument is of length zero in parlapply()

In my code:

clusterExport(cl, c('func', 'a1', 'b1'),envir=environment())

res <- parLapply(cl, 1:length(x), function(x, datax) { func(a1[x], b1[x])})
stopCluster(cl)

Also inside the func function, if I am using

if(length(data[]==0){}

then it works fine without any error. But as soon as I change it to

if(nrow(data[]==0){}

I get the following error:

Error in checkForRemoteErrors(val) :
one node produced an error: argument is of length zero

There are many if and else with nrow(data[]>= 1) for that it works just fine.

Its just the nrow(data[]==0) position when this all gets triggered.

Please assist and let me know why am I facing this and how to resolve.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source