Title: | Lightweight Infrastructure for Handling Multiple R Markdown Documents |
---|---|
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. |
Authors: | Thibaut Jombart [aut, cre], Amy Gimma [ctb], Tim Taylor [aut] |
Maintainer: | Thibaut Jombart <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.1 |
Built: | 2024-11-01 04:24:39 UTC |
Source: | https://github.com/reconverse/reportfactory |
Compile one or several R Markdown reports
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"), ... )
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"), ... )
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 |
Invisble NULL (called for side effects only).
Print contents of directories in a tree-like format.
factory_overview(path = ".", ...)
factory_overview(path = ".", ...)
path |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
... |
Additional arguments passed to |
Invisibly returns a character of the files and directories within the desired folder.
This function can be used to install package dependencies based on the reports within the factory.
install_deps(factory = ".", update = FALSE, ...)
install_deps(factory = ".", update = FALSE, ...)
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 |
Invisble NULL (called for side effects only).
list_deps()
to list dependencies of packages
List package dependencies based on the reports and scripts within the report_sources and scripts directories respectively.
list_deps( factory = ".", missing = FALSE, check_r = TRUE, exclude_readme = TRUE, parse_first = FALSE )
list_deps( factory = ".", missing = FALSE, check_r = TRUE, exclude_readme = TRUE, parse_first = FALSE )
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 |
A character vector of package dependencies.
This function requires that any R scripts present in the factory are valid syntax else the function will error.
This function can be used to list available report outputs stored in the
factory, in inside the outputs
folder (or any subfolder within).
list_outputs(factory = ".", pattern = NULL, ...)
list_outputs(factory = ".", pattern = NULL, ...)
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 |
A character vector containing the names of the reports in the specified factory (empty if there were no files).
This function can be used to list available reports stored in the factory, in
inside the report_sources
folder (or any subfolder within).
list_reports(factory = ".", pattern = NULL, ...)
list_reports(factory = ".", pattern = NULL, ...)
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 |
A character vector containing the names of the reports in the specified factory (empty if there were no files).
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.
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 )
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 )
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 |
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 in outputs()
.
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 to here::here()
the report factory folder location (invisibly)
f1 <- new_factory("new_factory_1", move_in = FALSE) f2 <- new_factory("new_factory_2", move_in = TRUE)
f1 <- new_factory("new_factory_1", move_in = FALSE) f2 <- new_factory("new_factory_2", move_in = TRUE)
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.
validate_factory(factory = ".")
validate_factory(factory = ".")
factory |
The path to the report factory or a folder within the desired factory. Defaults to the current directory. |
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/';
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.