| Title: | Templated Word and PowerPoint Reporting of 'nlmixr2' Fitting Results |
|---|---|
| Description: | This allows you to generate reporting workflows around 'nlmixr2' analyses with outputs in Word and PowerPoint. You can specify figures, tables and report structure in a user-definable 'YAML' file. Also you can use the internal functions to access the figures and tables to allow their including in other outputs (e.g. R Markdown). |
| Authors: | John Harrold [aut, cre] (ORCID: <https://orcid.org/0000-0003-2052-4373>) |
| Maintainer: | John Harrold <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 0.2.2 |
| Built: | 2026-06-03 00:00:12 UTC |
| Source: | https://github.com/nlmixr2/nlmixr2rpt |
nlmixr2 ReportCreates figures specified in a rptyaml file
build_figures( obnd = NULL, fit = NULL, rptdetails = NULL, cat_covars = NULL, cont_covars = NULL, verbose = TRUE )build_figures( obnd = NULL, fit = NULL, rptdetails = NULL, cat_covars = NULL, cont_covars = NULL, verbose = TRUE )
obnd |
|
fit |
|
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 |
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
# 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)# 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)
nlmixr2 ReportCreates tables specified in a rptyaml file
build_tables( obnd = NULL, fit = NULL, rptdetails = NULL, cat_covars = NULL, cont_covars = NULL, verbose = TRUE )build_tables( obnd = NULL, fit = NULL, rptdetails = NULL, cat_covars = NULL, cont_covars = NULL, verbose = TRUE )
obnd |
onbrand report object to have report elements appended to |
fit |
nlmixr2 fit object to be reported |
rptdetails |
object creating 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 |
List containing the tables with the following structure:
"rpttabs" - List of tables with names corresponding to the
table ids in the yaml file. It contains the elements from the yamle file
and the following elements:
"table" - Result of build (t_res object)
"orientation" - Table orientation ("portrait" or "landscape")
"isgood" - Boolean variable indicating success or failure
"skip" - Boolean variable indicating whether the table should be skipped during reporting
"tmsgs" - Vector of messages
"cmd" - Original plot generation command
"cmd_proc" - Plot generation command after processing for placeholders
"height" - Table height
"width" - Table 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
# 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 tables btres = build_tables(obnd = obnd, fit = fit, rptdetails = rptdetails)# 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 tables btres = build_tables(obnd = obnd, fit = fit, rptdetails = rptdetails)
Attempts to evaluate a string as a chunk of R code.
eval_str(estr = "", fit = NULL)eval_str(estr = "", fit = NULL)
estr |
Object creating when reading in rptyaml file |
fit |
nlmixr2 fit object to be reported |
String containing the evaled as a character or the original string
res = eval_str(estr="ls()")res = eval_str(estr="ls()")
For a given figure id and report type this will pull out the dimensions of the figure.
fetch_fdim(obnd = NULL, fid = NULL, fdim = "width", rptdetails = NULL)fetch_fdim(obnd = NULL, fid = NULL, fdim = "width", rptdetails = NULL)
obnd |
onbrand report object to have report elements appended to |
fid |
Figure ID used in the figures section of the yaml file |
fdim |
Dimension to fetch either "width" or "height" |
rptdetails |
Object creating when reading in rptyaml file |
ggplot object
library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below 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 fetch_fdim(obnd=obnd, fid="bad_figure", fdim="width", rptdetails=rptdetails) fetch_fdim(obnd=obnd, fid="bad_figure", fdim="height", rptdetails=rptdetails)library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below 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 fetch_fdim(obnd=obnd, fid="bad_figure", fdim="width", rptdetails=rptdetails) fetch_fdim(obnd=obnd, fid="bad_figure", fdim="height", rptdetails=rptdetails)
Creates an nlmixr2 fit example using posthoc estimation
method for testing purposes.
displayed on the terminal
following:
fetch_fit_example(use_cache = TRUE)fetch_fit_example(use_cache = TRUE)
use_cache |
Boolean variable used to cache the fit process for the current R session. |
Example nlmixr2 fit object
fit = fetch_fit_example()fit = fetch_fit_example()
Fetches analysis options from the report yaml applies it to strings.
fetch_option(rptdetails, option = NULL, fit = NULL, verbose = TRUE)fetch_option(rptdetails, option = NULL, fit = NULL, verbose = TRUE)
rptdetails |
Object creating when reading in rptyaml file |
option |
String containing the option to fetch (see below) |
fit |
nlmixr2 fit object to be reported |
verbose |
Boolean variable when set to |
The option can be one of the following (default: NULL):
"output_dir" - Directory to place figures that are generated (default: tempdir())
"resolution" - Resolution of figure files (default: 300)
List containing the following information about the output directory
"isgood" - Boolean variable indicating success or failure
"msgs" - Vector of messages
"value" - The value of the option or the default if not
specified
library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below 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 fetch_option(rptdetails, option="output_dir", fit=fit)library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below 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 fetch_option(rptdetails, option="output_dir", fit=fit)
nlmixr2 Parameter Estimate Table for ReportingGenerates a flextable containting the parameter estimates.
gen_pest_table(obnd = NULL, fit = NULL, rptdetails = NULL, verbose = TRUE)gen_pest_table(obnd = NULL, fit = NULL, rptdetails = NULL, verbose = TRUE)
obnd |
onbrand report object to have report elements appended to |
fit |
nlmixr2 fit object to be reported |
rptdetails |
object creating when reading in rptyaml file |
verbose |
Boolean variable when set to TRUE (default) messages will be displayed on the terminal |
List with the following elements
"isgood" - Boolean variable indicating success or failure
"msgs" - Vector of messages
"ft" - Parameter estimates as a flextable object
"df" - Parameter estimates as a data.frame
library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below 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 gen_pest_table(obnd = obnd, fit = fit, rptdetails = rptdetails, verbose = TRUE)library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below 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 gen_pest_table(obnd = obnd, fit = fit, rptdetails = rptdetails, verbose = TRUE)
ggplot Object with Error MessageTakes a vector of messages and returns a ggplot object with the text in the figure. This can be used in automated figure generation to cascade an error message to the end user.
mk_error_fig(msgs)mk_error_fig(msgs)
msgs |
Vector of error messages |
ggplot object
mk_error_fig("This is an error")mk_error_fig("This is an error")
flextable Object with Error MessageTakes a vector of messages and returns a flextable object with the
text in the table. This can be used in automated table generation to
cascade an error message to the end user.
mk_error_tab(msgs)mk_error_tab(msgs)
msgs |
Vector of error messages |
list with a single flextable object
error_tab = mk_error_tab("This is an error") error_tab$ft[[1]]error_tab = mk_error_tab("This is an error") error_tab$ft[[1]]
Takes placeholder information from the rptyaml file and applies it to strings.
process_ph(str, rptdetails)process_ph(str, rptdetails)
str |
String to process |
rptdetails |
Object creating when reading in rptyaml file
(default: |
processed string
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 str = "This is ===CMPD===" process_ph(str, rptdetails)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 str = "This is ===CMPD===" process_ph(str, rptdetails)
nlmixr2 Fit Results to PowerPoint and WordAppends nlmixr2 fit results to an onbrand report object with the
content and format of the report in the supplied yaml file
report_fit( obnd = NULL, fit = NULL, placeholders = NULL, cat_covars = NULL, cont_covars = NULL, parameters = NULL, rptyaml = system.file(package = "nlmixr2rpt", "templates", "report_fit.yaml"), verbose = FALSE )report_fit( obnd = NULL, fit = NULL, placeholders = NULL, cat_covars = NULL, cont_covars = NULL, parameters = NULL, rptyaml = system.file(package = "nlmixr2rpt", "templates", "report_fit.yaml"), verbose = FALSE )
obnd |
onbrand report object to have report elements appended to. |
fit |
nlmixr2 fit object to be reported. |
placeholders |
Manual placeholders, see |
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. |
parameters |
list with element names for each parameter to overwrite defaults in yaml file. |
rptyaml |
yaml file containing the report elements and structure. |
verbose |
Boolean variable when set to TRUE messages will be . |
onbrand object with the report elements added.
library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below fit = fetch_fit_example() # Appening fit results obnd_pptx = report_fit( fit = fit, rptyaml = system.file(package="nlmixr2rpt", "examples", "report_fit_test.yaml"), obnd = obnd) # Writing the report to a file save_report(obnd, file.path(tempdir(), "report.pptx"))library(onbrand) obnd = read_template( template = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.pptx"), mapping = system.file(package="nlmixr2rpt", "templates","nlmixr_obnd_template.yaml")) # This will create an example fit object to use in the examples below fit = fetch_fit_example() # Appening fit results obnd_pptx = report_fit( fit = fit, rptyaml = system.file(package="nlmixr2rpt", "examples", "report_fit_test.yaml"), obnd = obnd) # Writing the report to a file save_report(obnd, file.path(tempdir(), "report.pptx"))
Converts curly braces to double curly braces in order to prevent interpertation with the cli package
safe_text(x)safe_text(x)
x |
String with curly braces |
String with curly braces escaped
safe_text("This string has curly {braces}")safe_text("This string has curly {braces}")
Takes a figure object, optionally stamps the image, and writes to a file dimensions of the figure.
write_figure( p_res = NULL, page = NULL, width = 3, height = 3, resolution = NULL, fig_file = NULL, fig_stamp = NULL, verbose = TRUE )write_figure( p_res = NULL, page = NULL, width = 3, height = 3, resolution = NULL, fig_file = NULL, fig_stamp = NULL, verbose = TRUE )
p_res |
ggplot, ggforce paginated object, or ggarrange object. |
page |
Page number to write or NULL for a ggplot object. |
width |
Width in inches. |
height |
Height in inches. |
resolution |
resolution in dpi. |
fig_file |
File name to write the figure to. |
fig_stamp |
Character object containing the text to stamp on the figure with optional ===file=== placeholder. |
verbose |
Boolean variable when set to TRUE (default) messages will be. displayed on the terminal |
list with the following
"isgood" - Boolean variable indicating success or failure
"msgs" - Vector of messages
library(ggplot2) write_figure( p_res = ggplot(), page = NULL, width = 3, height = 3, resolution = 200, fig_file = file.path(tempdir(), "write_figure_example.png"), fig_stamp = "stamp", verbose = TRUE)library(ggplot2) write_figure( p_res = ggplot(), page = NULL, width = 3, height = 3, resolution = 200, fig_file = file.path(tempdir(), "write_figure_example.png"), fig_stamp = "stamp", verbose = TRUE)
report_fit.yaml FileReads in the report yaml file and looks it to make sure it has all the necessary fields for the given report.
yaml_read_fit( obnd = NULL, rptyaml = NULL, placeholders = NULL, parameters = NULL, fit = NULL )yaml_read_fit( obnd = NULL, rptyaml = NULL, placeholders = NULL, parameters = NULL, fit = NULL )
obnd |
onbrand report object to have report elements appended to. |
rptyaml |
yaml file containing the report elements and structure. |
placeholders |
list of placeholders to overwrite defaults in the yaml file. |
parameters |
list with element names for each parameter to overwrite at runtime.
with a named list for example RUN may be "RUNN" in the yaml file. To
overwrite this just provide |
fit |
nlmixr2 fit object to be reported. |
List containing the following information about the report
"isgood" - Boolean variable indicating success or failure
"msgs" - Vector of messages
"rpttype" - Type of onbrand report ("Word" or "PowerPoint")
"rptfigfmt" - Default figure formatting (orientation and dimensions)
"rpttabfmt" - Default table formatting (orientation and dimensions)
"rptdetails" - Contents of the yaml file
"rptcont" - Contents of the report to generate
# 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 yaml_read_res = yaml_read_fit( obnd = obnd, rptyaml = system.file(package="nlmixr2rpt", "examples", "report_fit_test.yaml"), fit = fit)# 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 yaml_read_res = yaml_read_fit( obnd = obnd, rptyaml = system.file(package="nlmixr2rpt", "examples", "report_fit_test.yaml"), fit = fit)