Title: | Lightweight Infrastructure for Handling Multiple R Markdown Documents |
Version: | 0.4.0 |
Description: | Provides an infrastructure for handling multiple R Markdown reports, including automated curation and time-stamping of outputs, parameterisation and provision of helper functions to manage dependencies. |
License: | MIT + file LICENSE |
URL: | https://github.com/reconverse/reportfactory |
BugReports: | https://github.com/reconverse/reportfactory/issues |
Encoding: | UTF-8 |
RoxygenNote: | 7.1.1 |
Suggests: | testthat, covr |
Imports: | rprojroot, fs, rmarkdown, utils, yaml, callr, rstudioapi, knitr |
SystemRequirements: | pandoc (>= 1.14) - http://pandoc.org |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2021-08-09 12:15:22 UTC; tim |
Author: | Thibaut Jombart [aut],
Amy Gimma [ctb],
Tim Taylor |
Maintainer: | Tim Taylor <tim.taylor@hiddenelephants.co.uk> |
Repository: | CRAN |
Date/Publication: | 2021-08-09 12:30:02 UTC |
Compile one or several R Markdown reports
Description
Compile one or several R Markdown reports
Usage
compile_reports(
reports = NULL,
factory = ".",
ignore.case = FALSE,
params = NULL,
quiet = TRUE,
subfolder = NULL,
timestamp = format(Sys.time(), "%Y-%m-%d_T%H-%M-%S"),
...
)
Arguments
reports |
Either a regular expression (passed directly to |
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
ignore.case |
if FALSE (default), the report pattern matching is case sensitive and if TRUE, case is ignored during matching. |
params |
A named list of parameters to be used for compiling reports,
passed to |
quiet |
A logical indicating if messages from R Markdown compilation
should be displayed; |
subfolder |
Name of subfolder to store results. Not required but helps distinguish output if mapping over multiple parameters. If provided, "subfolder" will be placed before the timestamp when storing compilation outputs. |
timestamp |
A character indicating the date-time format to be used for timestamps. Timestamps are used in the folder structure of outputs. If NULL, the format format(Sys.time(), "%Y-%m-%d_T%H-%M-%S") will be used. Note that the timestamp corresponds to the time of the call to compile_reports(), so that multiple reports compiled using a single call to the function will have identical timestamps. |
... |
further arguments passed to |
Value
Invisble NULL (called for side effects only).
Generate an overview of a report factory
Description
Print contents of directories in a tree-like format.
Usage
factory_overview(path = ".", ...)
Arguments
path |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
... |
Additional arguments passed to |
Value
Invisibly returns a character of the files and directories within the desired folder.
Install dependencies of reports within
Description
This function can be used to install package dependencies based on the reports within the factory.
Usage
install_deps(factory = ".", update = FALSE, ...)
Arguments
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
update |
A logical indicating if packages which are already installed
should be re-installed ( |
... |
Arguments to be passed to |
Value
Invisble NULL (called for side effects only).
See Also
list_deps()
to list dependencies of packages
List dependencies of reports within a factory
Description
List package dependencies based on the reports and scripts within the report_sources and scripts directories respectively.
Usage
list_deps(
factory = ".",
missing = FALSE,
check_r = TRUE,
exclude_readme = TRUE,
parse_first = FALSE
)
Arguments
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
missing |
A logical indicating if only missing dependencies should be
listed ( |
check_r |
If true, R scripts contained within the factory will also be checked. Note that this will error if the script cannot be parsed. |
exclude_readme |
If TRUE (default) README files will not be checked for dependencies. |
parse_first |
If |
Value
A character vector of package dependencies.
Note
This function requires that any R scripts present in the factory are valid syntax else the function will error.
List outputs of the factory
Description
This function can be used to list available report outputs stored in the
factory, in inside the outputs
folder (or any subfolder within).
Usage
list_outputs(factory = ".", pattern = NULL, ...)
Arguments
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
pattern |
An optional regular expression used to look for specific patterns in report names. |
... |
additional parameters to pass to |
Value
A character vector containing the names of the reports in the specified factory (empty if there were no files).
List reports in the factory
Description
This function can be used to list available reports stored in the factory, in
inside the report_sources
folder (or any subfolder within).
Usage
list_reports(factory = ".", pattern = NULL, ...)
Arguments
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
pattern |
An optional regular expression used to look for specific patterns in report names. |
... |
additional parameters to pass to |
Value
A character vector containing the names of the reports in the specified factory (empty if there were no files).
Create a new report factory
Description
This function can be used to create a new report factory. By default, the factory is created with a template of report, and the working environment is moved to the newly created factory.
Usage
new_factory(
factory = "new_factory",
path = ".",
report_sources = "report_sources",
outputs = "outputs",
move_in = TRUE,
create_README = TRUE,
create_example_report = TRUE,
create_data_folders = TRUE,
create_scripts_folder = TRUE,
use_here = TRUE,
use_rproj = TRUE,
create_gitignore = TRUE
)
Arguments
factory |
The name of the report factory to be created. |
path |
The folder where the report factory should be created. This will default to the current directory. |
report_sources |
The name of the folder to be used for report templates; defaults to 'report_sources/'. |
outputs |
The name of the folder to be used for saving the built reports; defaults to 'outputs/'. |
move_in |
A |
create_README |
A |
create_example_report |
A |
create_data_folders |
a |
create_scripts_folder |
a |
use_here |
a |
use_rproj |
a |
create_gitignore |
a |
Details
Assuming the default names are used then new_factory
will create a report
factory folder (called "new_factory") that includes:
-
report_sources
: a folder for storing the .Rmd reports -
outputs
: a folder storing the compiled reports -
factory_config
: a control file used to anchor a report factory
Depending on the values of the logical arguments, the factory may also include:
-
README.md
: Example README with instructions on how to use report factory. -
.gitignore
: a file used to tell git to ignore certain files including the produced outputs inoutputs()
. -
data/raw/
: a folder for storing raw data -
data/raw/example_data.csv
: a set of data for use with the example report -
data/clean/
: a folder for storing cleaned data -
scripts/
: a folder to store additional code that may be called in reports -
report_sources/example_report.Rmd
: an example .Rmd report template -
.here
: a file to anchor calls tohere::here()
Value
the report factory folder location (invisibly)
Examples
f1 <- new_factory("new_factory_1", move_in = FALSE)
f2 <- new_factory("new_factory_2", move_in = TRUE)
Inspect and validate the content of a factory
Description
validate_factory()
can be used to inspect the content of a factory and make
everything looks fine. This includes various sanity checks listed in details
that will error if a problem is found.
Usage
validate_factory(factory = ".")
Arguments
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
Details
Checks run on the factory include:
the factory directory exists;
the factory_config file exist;
all mandatory folders exist - by default these are 'report_sources/' and 'outputs/';
Value
A list with 4 entries:
root - the root folder path of the factory;
factory_name - the name of the report factory;
report_sources - the name of the report_sources folder; and
outputs - the name of the outputs folder.