Skip to contents

Creates figures specified in a rptyaml file

Usage

build_figures(
  obnd = NULL,
  fit = NULL,
  rptdetails = NULL,
  cat_covars = NULL,
  cont_covars = NULL,
  verbose = TRUE
)

Arguments

obnd

onbrand report object to have report elements appended to

fit

nlmixr2 fit object to be reported

rptdetails

Object created when reading in rptyaml file

cat_covars

character vector of categorical covariates to overwrite defaults in yaml file

cont_covars

character vector of continuous covariates to overwrite defaults in yaml file

verbose

Boolean variable when set to TRUE (default) messages will be displayed on the terminal

Value

List containing the figures with the following structure:

  • "rptfigs" - List of figures with names corresponding to the figure ids in the yaml file. Each figure ID contains the following elements:

    • "figure" - list of figure file names for the current fid

    • "orientation" - Figure orientation ("portrait" or "landscape")

    • "isgood" - Boolean variable indicating success or failure

    • "skip" - Boolean variable indicating whether the figure should be skipped during reporting

    • "fmsgs" - Vector of messages

    • "cmd" - Original plot generation command

    • "cmd_proc" - Plot generation command after processing for placeholders

    • "height" - Figure height

    • "width" - Figure width

    • "caption" - Caption for Word

    • "caption_proc" - Caption for Word after processing for placeholders

    • "title" - Slide title for PowerPoint

    • "title_proc" - Slide title for PowerPoint after processing for placeholders

  • "isgood" - Boolean variable indicating success or failure

  • "msgs" - Vector of messages

Examples

# We need an onbrand object to use below
library(onbrand)  
obnd = read_template(
 template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.docx"),
 mapping  = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml"))

# We also need an nlmixr fit object
fit = fetch_fit_example()

# This reads in the report details as well
rptdetails = yaml_read_fit(
 obnd    = obnd,
 rptyaml = system.file(package="nlmixr2rpt", "examples", "report_fit_test.yaml"),
 fit     = fit)$rptdetails

# Now we will build the figures
bfres = build_figures(obnd       = obnd,
                     fit        = fit, 
                     rptdetails = rptdetails)
#> 
#> Attaching package: ‘xpose’
#> The following object is masked from ‘package:stats’:
#> 
#>     filter
#> 
#> ── Building report figures 
#> → dv_vs_pred
#> `geom_smooth()` using formula = 'y ~ x'
#> `geom_smooth()` using formula = 'y ~ x'
#>
#>   /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmparONJf/RUNN/dv_vs_pred-Word.png
#> → bad_figure
#> 
#> ── Figure generation failed 
#> → figure id: bad_figure
#> → Unable to generate figure
#> →  -> call:    eval, parse(text = finfo[["cmd_proc"]])
#> →  -> message: object 'bad_figure_command' not found
#> → command run:
#> → bad_figure_command
#>
#>   /var/folders/pq/7srbf_fx3rd3k706hgxkg61r0000gp/T//RtmparONJf/RUNN/bad_figure-Word.png
#> → skip_figure