# \donttest{
if (fz_available()) {
# run inside a throwaway directory: fz writes results/ and .fz/ under cwd
ex_dir <- file.path(tempdir(), "fz-fzr-example")
dir.create(ex_dir, showWarnings = FALSE)
owd <- setwd(ex_dir)
tf <- tempfile(fileext = ".sh")
writeLines(c(
"#!/bin/sh",
"echo result = $(( ${x~0} + ${y~0} )) > output.txt"
), tf)
model <- list(
varprefix = "$", delim = "{}", formulaprefix = "@", commentline = "#",
output = list(result = "grep result output.txt | cut -d= -f2")
)
results <- fzr(tf, list(x = c(1L, 2L), y = 3L), model,
calculators = "sh://bash input.sh")
setwd(owd)
unlink(ex_dir, recursive = TRUE)
}
# }
Run the code above in your browser using DataLab