Last active
August 9, 2017 14:04
-
-
Save HenrikBengtsson/7e454f677bdde2aa0adf775479a7c694 to your computer and use it in GitHub Desktop.
Evaluate unsafe R expression inside Linux container
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library("future") | |
## Launch Linux container rocker/r-base in background | |
cl <- makeClusterPSOCK("localhost", | |
rscript = c("docker", "run", "--net=host", "rocker/r-base", "Rscript"), | |
rscript_args = c("-e", shQuote("install.packages('future')"))) | |
## Evaluate R expression inside container | |
f <- cluster({ some_unsafe_call() }, workers = cl) | |
v <- value(f) | |
## Alternatively, evaluate all future expressions inside the container | |
plan(cluster, workers = cl) | |
a %<-% { some_unsafe_call() } | |
b %<-% { another_unsafe_call() } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment