Produces a string with <col-name>: <col-definition> format which can be included in a table note providing a more informative definition with the column name. The column definition can be generated from the short name or the label (but note that these could frequently be the same).

ys_col_note(
  .spec,
  ...,
  .unit = FALSE,
  .title_case = FALSE,
  .sep = ": ",
  .to_string = TRUE,
  .collapse = "; ",
  .width = NULL,
  .type = c("short", "label")
)

Arguments

.spec

a yspec object.

...

passed to ys_select().

.unit

logical; if TRUE, then append the unit surrounded by parens to the column definition.

.title_case

logical; if TRUE then the column definition text is passed through tools::toTitleCase().

.sep

a string to separate column name and column definition; usually a space should be included as the terminal character (see default).

.to_string

logical; if TRUE, then a single string is returned.

.collapse

a string to separate items when .to_string is TRUE; usually a space should be included as the terminal character (see default).

.width

if numeric and .to_string is TRUE, then the result is passed through base::strwrap().

.type

selects if the column definition is generated from calling ys_get_short() or ys_get_label().

Value

A string of length one when .to_string is TRUE or a character vector if .to_string is FALSE.

Examples

spec <- ys_help$spec()

ys_col_note(spec, AST, ALT, SCR, .unit = TRUE) 
#> [1] "AST: aspartate aminotransferase ; ALT: alanine aminotransferase ; SCR: serum creatinine (mg/dL)"