Export an agent, informant, multiagent, or table scan to HTML
Export an agent, informant, multiagent, or table scan to HTML
The agent, informant, multiagent, and the table scan object can be easily written as HTML with export_report(). Furthermore, any report objects from the agent, informant, and multiagent (generated using get_agent_report(), get_informant_report(), and get_multiagent_report()) can be provided here for HTML export. Each HTML document written to disk is self-contained and easily viewable in a web browser.
An agent object of class ptblank_agent, an informant of class ptblank_informant, a multiagent of class ptblank_multiagent, a table scan of class ptblank_tbl_scan, or, customized reporting objects (ptblank_agent_report, ptblank_informant_report, ptblank_multiagent_report.wide, ptblank_multiagent_report.long).
filename: File name
scalar<character> // required
The filename to create on disk for the HTML export of the object provided. It's recommended that the extension ".html" is included.
path: File path
scalar<character> // default:NULL (optional)
An optional path to which the file should be saved (this is automatically combined with filename).
quiet: Inform (or not) upon file writing
scalar<logical> // default:FALSE
Should the function not inform when the file is written?
Returns
Invisibly returns TRUE if the file has been written.
Examples
A: Writing an agent report as HTML
Let's go through the process of (1) developing an agent with a validation plan (to be used for the data quality analysis of the small_table
dataset), (2) interrogating the agent with the interrogate() function, and (3) writing the agent and all its intel to a file.
Creating an action_levels object is a common workflow step when creating a pointblank agent. We designate failure thresholds to the warn, stop, and notify states using action_levels().
Now create a pointblank agent object and give it the al object (which serves as a default for all validation steps which can be overridden). The data will be referenced in the tbl argument with a leading ~.
If you're consistently writing agent reports when periodically checking data,
we could make use of affix_date() or affix_datetime() depending on the
granularity you need. Here's an example that writes the file with the format:
"<filename>-YYYY-mm-dd_HH-MM-SS.html".
Let's go through the process of (1) creating an informant object that minimally describes the small_table dataset, (2) ensuring that data is captured from the target table using the incorporate() function, and (3) writing the informant report to HTML.
Create a pointblank informant object with create_informant() and the small_table dataset. Use incorporate() so that info snippets are integrated into the text.
informant <-
create_informant(
tbl = ~ small_table,
tbl_name = "small_table",
label = "`export_report()`"
) %>%
info_snippet(
snippet_name = "high_a",
fn = snip_highest(column = "a")
) %>%
info_snippet(
snippet_name = "low_a",
fn = snip_lowest(column = "a")
) %>%
info_columns(
columns = a,
info = "From {low_a} to {high_a}."
) %>%
info_columns(
columns = starts_with("date"),
info = "Time-based values."
) %>%
info_columns(
columns = date,
info = "The date part of `date_time`."
) %>%
incorporate()
The informant report can be written to an HTML file with export_report(). Let's do this with affix_date() so the filename has a datestamp.