Building a system file will produce templates for R and other languages. This function provides a method to make local copies of these templates.

system_fetch_template(
  cfg,
  template = "Simulation",
  overwrite = FALSE,
  output_directory = getwd()
)

Arguments

cfg

ubiquity system object

template

template type

overwrite

if TRUE the new system file will overwrite any existing files present

output_directory

directory where workshop files will be placed (getwd())

Value

List with vectors of template sources, destinations and corresponding write success (write_file), also a list element indicating the overall success of the function call (isgood)

Details

The template argument can have the following values

  • "Simulation" produces analysis_simulate.R: R-Script named with placeholders used to run simulations

  • "Estimation" produces analysis_estimate.R: R-Script named with placeholders used to perform naive-pooled parameter estimation

  • "NCA" produces analysis_nca.R: R-Script to perform non-compartmental analysis (NCA) and report out the results

  • "ShinyApp" produces ubiquity_app.R, server.R and ui.R: files needed to run the model through a Shiny App either locally or on a Shiny Server

  • "Model Diagram" produces system.svg: SVG template for producing a model diagram (Goto https://inkscape.org for a free SVG editor)

  • "Shiny Rmd Report" produces system_report.Rmd and test_system_report.R: R-Markdown file used to generate report tabs for the Shiny App and a script to test it

  • "myOrg" produces myOrg.R: R-Script for defining functions used within your organization

  • "mrgsolve" produces system_mrgsolve.cpp: text file with the model and the currently selected parameter set in mrgsolve format

  • "Berkeley Madonna" produces system_berkeley_madonna.txt: text file with the model and the currently selected parameter set in Berkeley Madonna format

  • "Adapt" produces system_adapt.for and system_adapt.prm: Fortran and parameter files for the currently selected parameter set in Adapt format.

Examples

# \donttest{
# Creating a system file from the mab_pk example
fr = system_new(file_name        = "system.txt", 
                system_file      = "mab_pk", 
                overwrite        = TRUE, 
                output_directory = tempdir())

# Building the system 
cfg = build_system(system_file  = file.path(tempdir(), "system.txt"),
      output_directory          = file.path(tempdir(), "output"),
      temporary_directory       = tempdir())
#> 
#> ── Building the system: /var/folders/xs/3gst8jln2q3c_01y4cg1rqp00000gn/T//RtmpKQ
#> → ubiquity:     https://r.ubiquity.tools
#> → Distribution: package (2.0.1)
#> → Compiling C version of system
#> → Loading the shared C library
#>  System built
#>  To fetch a new analysis template use `system_fetch_template`
#>  For example:
#>    fr = system_fetch_template(cfg, template = "Simulation")
#>    fr = system_fetch_template(cfg, template = "Estimation")

# Creating a simulation template
fr =  system_fetch_template(cfg, 
      template         = "Simulation", 
      output_directory = tempdir())
#> → Creating file: /var/folders/xs/3gst8jln2q3c_01y4cg1rqp00000gn/T//RtmpKQQlha/analysis_simulate.R
# }