# NOT RUN {
# Take the `small_table` and
# assign it to `test_table`; we'll
# modify it later
test_table <- small_table
# Generate an informant object, add
# two snippets with `info_snippet()`,
# add information with some other
# `info_*()` functions and then
# `incorporate()` the snippets into
# the info text
informant <-
create_informant(
read_fn = ~ test_table,
tbl_name = "test_table",
label = "An example."
) %>%
info_snippet(
snippet_name = "row_count",
fn = ~ . %>% nrow()
) %>%
info_snippet(
snippet_name = "max_a",
fn = snip_highest(column = "a")
) %>%
info_columns(
columns = vars(a),
info = "In the range of 1 to {max_a}. (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."
) %>%
incorporate()
# We can print the `informant` object
# to see the information report
# Let's modify `test_table` to give
# it more rows and an extra column
test_table <-
dplyr::bind_rows(test_table, test_table) %>%
dplyr::mutate(h = a + c)
# Using `incorporate()` will cause
# the snippets to be reprocessed, and,
# the info text to be updated
informant <-
informant %>% incorporate()
# }
Run the code above in your browser using DataLab