library(fs)
library(withr)
with_tempdir({
## create 'src' directory
dir_create("src")
## put R scripts containing calls to
## 'cmd_assign' in the 'src' directory
writeLines(c("cmd_assign(x = 1, .out = 'out/results.rds')",
"results <- x + 1",
"saveRDS(results, file = .out)"),
con = "src/results.R")
writeLines(c("cmd_assign(x = 1, .out = 'out/more_results.rds')",
"more_results <- x + 2",
"saveRDS(more_results, file = .out)"),
con = "src/more_results.R")
## call 'shell_script()'
shell_script(path_files = "src",
dir_shell = ".")
## shell script has been created
dir_tree()
## print contents of shell script
cat(readLines("workflow.sh"), sep = "\n")
})
Run the code above in your browser using DataLab