I've been exploring the parSapply() function in parallel package.
In the sapply() function we can do this:
result = sapply(1:10, function(x){print('haha'); return(x)})
This prints "haha" in each iteration and stores 1:10 in "result".
When I try to do the same thing using parSapply():
cores = detectCores() - 1
cl = makeCluster(cores)
result = parSapply(cl,1:10, function(x){print('haha'); return(x)})
Only 1:10 got stored in result but the 'haha's are not printed. Wondering how to fix this? Thanks!