Skip to contents

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)



An agent object of class ptblank_agent. If an object is provided here, then filename must not be provided.


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 agent.


An optional path to the YAML file (combined with filename).


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 FALSE so expressions as written will be retained in the YAML representation.


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 <- 
    "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
  warn_fraction: 0.1
  stop_fraction: 0.25
  notify_fraction: 0.35
- 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().

Function ID