When creating a diagram from a dm
using dm_draw()
the table descriptions set with dm_set_table_description()
will be displayed.
Usage
dm_set_table_description(dm, ...)
dm_get_table_description(dm, table = NULL, ...)
dm_reset_table_description(dm, table = NULL, ...)
Arguments
- dm
A
dm
object.- ...
For
dm_set_table_description()
: Descriptions for tables to set in the formdescription = table
.tidyselect
is supported, seedplyr::select()
for details on the semantics.For
dm_get_table_description()
anddm_reset_table_description()
: These dots are for future extensions and must be empty.- table
One or more table names, unquoted, for which to
get information about the current description(s) with
dm_get_table_description()
.remove descriptions with
dm_reset_table_description()
.
In both cases the default applies to all tables in the
dm
.
Value
For dm_set_table_description()
: A dm
object containing descriptions for specified tables.
For dm_get_table_description
: A named vector of tables, with the descriptions in the names.
For dm_reset_table_description()
: A dm
object without descriptions for specified tables.
Details
Multi-line descriptions can be achieved using the newline symbol \n
.
Descriptions are set with dm_set_table_description()
.
The currently set descriptions can be checked using dm_get_table_description()
.
Descriptions can be removed using dm_reset_table_description()
.
Examples
desc_flights <- rlang::set_names(
"flights",
paste(
"On-time data for all flights",
"that departed NYC (i.e. JFK, LGA or EWR) in 2013.",
sep = "\n"
)
)
nyc_desc <- dm_nycflights13() %>%
dm_set_table_description(
!!desc_flights,
"Weather at the airport of\norigin at time of departure" = weather
)
nyc_desc %>%
dm_draw()
dm_get_table_description(nyc_desc)
#> On-time data for all flights\nthat departed NYC (i.e. JFK, LGA or EWR) in 2013.
#> "flights"
#> Weather at the airport of\norigin at time of departure
#> "weather"
dm_reset_table_description(nyc_desc, flights) %>%
dm_draw(font_size = c(header = 18L, table_description = 9L, column = 15L))
pull_tbl(nyc_desc, flights) %>%
labelled::label_attribute()
#> [1] "On-time data for all flights\nthat departed NYC (i.e. JFK, LGA or EWR) in 2013."