# NOT RUN {
cl <- new_cluster(2)
# This function will be copied to each node
f <- function() 1 + 1
cl %>% cluster_map(f)
# The function will be called on each node
cl %>% cluster_map("Sys.getpid")
# cluster_call() provides a slightly simpler sytanx where you just
# provide an expression to be executed on each worke
cl %>% cluster_call(1 + 1)
cl %>% cluster_call(Sys.getpid())
invisible(cl %>% cluster_call(x <- runif(1)))
cl %>% cluster_call(x)
# }
Run the code above in your browser using DataLab