knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
source(system.file("extdata", "vignette-helpers.R", package = "ospsuite.reportingengine"))
require(ospsuite.reportingengine)

In Mean Model and Population workflows, title pages can be included using the reportTitle input argument.

The example below will be used to illustrate the available options when adding a title page to the final report.

Code

# Get the pkml simulation file: "MiniModel2.pkml"
simulationFile <- system.file("extdata", "MiniModel2.pkml",
  package = "ospsuite.reportingengine"
)

# Define the input parameters
outputA <- Output$new(
  path = "Organism|A|Concentration in container",
  displayName = "Concentration of A",
  displayUnit = "nmol/ml"
)

setA <- SimulationSet$new(
  simulationSetName = "A",
  simulationFile = simulationFile,
  outputs = outputA
)

Add a title only

When only a title is needed as a title page, the workflow will internally add the markdown title tag, "#", to the reportTitle as illustrated below.

Code

# Create the workflow instance with the report title
workflow <-
  MeanModelWorkflow$new(
    simulationSets = setA,
    workflowFolder = "Example-1",
    reportTitle = "A meaningful title"
  )

# Set the workflow tasks to be run
workflow$activateTasks(c("simulate", "plotTimeProfilesAndResiduals"))

# Run the workflow
workflow$runWorkflow()

cat(includeReportFromWorkflow(workflow))

Add a title page

When the length of reportTitle is longer than 1, the workflow will assume reportTitle is a more advanced title page already formatted for markdown. In such cases, reportTitle will used as is.

In the example below, the content of a more advanced title page is defined. The corresponding page includes

Code

titlePage <- c(
  anchor("title-page"),
  "",
  "# A meaningful title",
  "",
  knitr::kable(
    data.frame(
      Date = Sys.Date(),
      Author = "OSP Suite - Reporting Engine",
      Subject = "Example Workflow"
    )
  )
)
# Here, it is more optimal to re-use the previous workflow
# since only the report title page is changed and the same results are used
workflow$inactivateTasks("simulate")

workflow$reportTitle <- titlePage

# Re-run the workflow with the new title page
workflow$runWorkflow()

cat(includeReportFromWorkflow(workflow))

Use a file as title page

Another option is to use a markdown file as cover page. In this case, the file path can directly be defined in reportTitle and the workflow will internally check that the file exists and include its content.

The example below save the previously defined title page as a file named :

Code

titlePageFile <- "title-page.md"
write(
  x = titlePage,
  file = titlePageFile
)
# Here, it is more optimal to re-use the previous workflow
# since only the report title page is changed and the same results are used
workflow$reportTitle <- titlePageFile

# Re-run the workflow with the new title page
workflow$runWorkflow()

cat(includeReportFromWorkflow(workflow))

Note Note that running the workflow won't delete the title page. The title file can be re-used if the workflow needs to be re-run.

file.exists(titlePageFile)
# Remove the workflow folders
unlink(workflow$workflowFolder, recursive = TRUE)
unlink(titlePageFile, recursive = TRUE)



Open-Systems-Pharmacology/OSPSuite.ReportingEngine documentation built on May 1, 2024, 12:27 p.m.