# NOT RUN {
if (interactive()) {
# Let's go through the process of
# developing an informant with information
# about the `small_table` dataset and then
# move all that to a pointblank YAML
# file; this will later be read in as a
# new informant and the target data will
# be incorporated into the info text
# (in one step) with
# `yaml_informant_incorporate()`
# Now create a pointblank `informant`
# object; the data will be referenced
# in a `read_fn` (a requirement for
# writing to YAML)
informant <-
create_informant(
read_fn = ~small_table,
label = "A simple example with the `small_table`."
)
# Then, as with any `informant` object, we
# can add information by using as many
# `info_*()` functions as we want
informant <-
informant %>%
info_columns(
columns = vars(a),
info = "In the range of 1 to 10. (SIMPLE)"
) %>%
info_columns(
columns = starts_with("date"),
info = "Time-based values (e.g., `Sys.time()`)."
) %>%
info_columns(
columns = "date",
info = "The date part of `date_time`. (CALC)"
) %>%
info_section(
section_name = "rows",
row_count = "There are {row_count} rows available."
) %>%
info_snippet(
snippet_name = "row_count",
fn = ~ . %>% nrow()
) %>%
incorporate()
# The informant can be written to a pointblank
# YAML file with `yaml_write()`
yaml_write(
informant = informant,
filename = "informant-small_table.yml"
)
# The 'informant-small_table.yml' file
# is available in the package through
# `system.file()`
yml_file <-
system.file(
"yaml", "informant-small_table.yml",
package = "pointblank"
)
# We can incorporate the data (which
# is accessible through the `read_fn`)
# into the info text through direct
# use of the YAML file with
# `yaml_informant_incorporate()`
informant <-
yaml_informant_incorporate(filename = yml_file)
class(informant)
# If it's desired to only create a new
# informant with the information in place
# (stopping short of processing), then the
# `yaml_read_informant()` function will
# be useful
informant <-
yaml_read_informant(filename = yml_file)
class(informant)
}
# }
Run the code above in your browser using DataLab