if (getRversion() >= "4.4.0") {
library(parallel)
cl <- makeClusterSequential()
print(cl)
y <- parLapply(cl, X = 1:3, fun = sqrt)
str(y)
pid <- Sys.getpid()
print(pid)
y <- clusterEvalQ(cl, Sys.getpid())
str(y)
abc <- 3.14
y <- clusterEvalQ(cl, { abc <- 42; abc })
str(y)
stopifnot(abc == 3.14)
}
Run the code above in your browser using DataLab