Created
August 11, 2016 16:40
-
-
Save dpastoor/e83a48c7646a72f5b4644560ef366f1e to your computer and use it in GitHub Desktop.
working parallel
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) | |
| library(mrgsolve) | |
| library(dplyr) | |
| data(extran3) | |
| ipar <- extran3 %>% dplyr::select(ID,CL,VC,KA) %>% distinct(ID) | |
| mod <- mrgsolve:::house() | |
| plan(multiprocess) | |
| f <- list() | |
| for (ii in 1:2) { | |
| f[[ii]] <- future({ | |
| data <- extran3 | |
| mod %>% Req(CP) %>% | |
| data_set(data) %>% | |
| mrgsim %>% as.data.frame %>% | |
| mutate(rep = ii) | |
| }) | |
| } | |
| v <- lapply(f, FUN = value) | |
| bind_rows(v) |
kylebaron
commented
Aug 11, 2016
Author
> devtools::session_info()
Session info ------------------------------------------------------------
setting value
version R version 3.3.0 (2016-05-03)
system x86_64, darwin15.4.0
ui RStudio (0.99.1198)
language (EN)
collate en_US.UTF-8
tz America/Detroit
date 2016-08-11
Packages ----------------------------------------------------------------
package * version date
assertthat 0.1 2013-12-06
codetools 0.2-14 2015-07-15
DBI 0.4-1 2016-05-08
devtools 1.11.1 2016-04-21
digest 0.6.10 2016-08-02
dplyr * 0.5.0 2016-06-24
future * 1.0.1 2016-08-11
globals 0.6.1 2016-02-03
lazyeval 0.2.0 2016-06-12
listenv 0.6.0 2015-12-28
magrittr 1.5 2014-11-22
memoise 1.0.0 2016-01-29
mrgsolve * 0.7.5.9000 2016-08-09
R6 2.1.2 2016-01-26
Rcpp 0.12.6 2016-07-19
RcppArmadillo 0.7.200.2.0 2016-07-24
rsconnect 0.4.3 2016-05-02
tibble 1.1 2016-07-04
withr 1.0.1 2016-02-04
source
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
Github (HenrikBengtsson/future@771d11b)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
Github (metrumresearchgroup/mrgsolve@777ba41)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
.libPaths("lib")
library(future)
library(future.BatchJobs)
library(mrgsolve)
library(dplyr)
mod <- mrgsolve:::house()
data <- expand.ev(amt=100,ID=1:20)
plan(batchjobs_sge, pathname="simple.tmpl")
f <- lapply(1:10, function(i) {
future({
mod %>%
Req(CP) %>%
data_set(data) %>%
mrgsim %>%
mutate(rep = i)
})
})
data <- lapply(f,value) %>% bind_rows
simple.tmpl
#!/bin/bash
#$ -N <%= job.name %>
#$ -j y
#$ -o <%= log.file %>
#$ -cwd
#$ -V
# we merge R output with stdout from SGE, which gets then logged via -o option
R CMD BATCH --no-save --no-restore "<%= rscript %>" /dev/stdout
exit 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment