yaml_agent_string | R Documentation |
With pointblank YAML, we can serialize an agent's validation plan (with
yaml_write()
), read it back later with a new agent (with
yaml_read_agent()
), or perform an interrogation on the target data table
directly with the YAML file (with yaml_agent_interrogate()
). The
yaml_agent_string()
function allows us to inspect the YAML generated by
yaml_write()
in the console, giving us a look at the YAML without needing
to open the file directly. Alternatively, we can provide an agent to the
yaml_agent_string()
and view the YAML representation of the validation plan
without needing to write the YAML to disk beforehand.
yaml_agent_string(agent = NULL, filename = NULL, path = NULL, expanded = FALSE)
agent |
An agent object of class |
filename |
The name of the YAML file that contains fields related to an
agent. If a file name is provided here, then agent object must not be
provided in |
path |
An optional path to the YAML file (combined with |
expanded |
Should the written validation expressions for an agent be
expanded such that tidyselect expressions for columns are evaluated,
yielding a validation function per column? By default, this is |
Nothing is returned. Instead, text is printed to the console.
There's a YAML file available in the pointblank package that's called
"agent-small_table.yml"
. The path for it can be accessed through
system.file()
:
yml_file_path <- system.file( "yaml", "agent-small_table.yml", package = "pointblank" )
We can view the contents of the YAML file in the console with the
yaml_agent_string()
function.
yaml_agent_string(filename = yml_file_path)
type: agent tbl: ~ tbl_source("small_table", "tbl_store.yml") tbl_name: small_table label: A simple example with the `small_table`. lang: en locale: en actions: warn_fraction: 0.1 stop_fraction: 0.25 notify_fraction: 0.35 steps: - col_exists: columns: vars(date) - col_exists: columns: vars(date_time) - col_vals_regex: columns: vars(b) regex: '[0-9]-[a-z]{3}-[0-9]{3}' - rows_distinct: columns: ~ - col_vals_gt: columns: vars(d) value: 100.0 - col_vals_lte: columns: vars(c) value: 5.0
Incidentally, we can also use yaml_agent_string()
to print YAML in the
console when supplying an agent object as the input. This can be useful for
previewing YAML output just before writing it to disk with yaml_write()
.
11-5
Other pointblank YAML:
yaml_agent_interrogate()
,
yaml_agent_show_exprs()
,
yaml_exec()
,
yaml_informant_incorporate()
,
yaml_read_agent()
,
yaml_read_informant()
,
yaml_write()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.