These functions allow you to embed attributes in data so that you only need to think about them once. Some functions may overwrite or delete attributes in data, so it is recommended that you create a meta data object with the build_meta function after you have set variable labels, groups, notes, abbreviations, and units.

set_variable_labels(data, ...)

set_variable_groups(data, ...)

set_variable_abbrs(data, ...)

set_variable_notes(data, ...)

set_variable_units(data, ...)

Arguments

data

a data frame.

...

name-value pairs of variable groups and names (see examples)

Value

a tibble, adorned with additional attributes based on user input.

Details

  • tibble_one will handle attributes of data automatically, e.g., replacing variable names with variable labels, and placing variable acronyms (i.e., abbreviations) at the bottom of the table in a footnote.

  • Use set_variable_labels() to set the values that will represent variables in table one.

  • Use set_variable_groups() to change the variables that are listed in the variable categories of table one.

  • Use set_variable_notes to add descriptions of variables that will be placed at the bottom of table one as a footnote.

  • Use set_variable_abbrs to indicate what acronyms in variable labels mean (see examples).

  • Use set_variable_units to indicate the unit of measurement for continuous variables.

For set_variable_labels, names are variables and values are labels. For example, writing gfr_variable = "estimated GFR" as an input to set_variable_labels will set the label for gfr_variable as the indicated string. Since GFR is an acronym, we would also want to use set_variable_abbrs() and say gfr_variable = c("GFR" = "glomerular filtration rate") (see examples).

Note

The set_variable_labels function in tibbleOne is a wrapper of the labelled function, developed by Joseph Larmarange.

Examples

df <- data.frame( gfr = c(1,2,3), sbp = c(3,2,1) ) df <- set_variable_labels(df, gfr = 'Estimated GFR', sbp = 'Systolic BP' ) df <- set_variable_units(df, gfr = 'mL/min/1.73 m2', sbp = 'mm Hg' ) df <- set_variable_abbrs(df, gfr = c("GFR" = "glomerular filtration rate", "min" = 'minute'), sbp = c("BP" = "blood pressure") ) df <- set_variable_notes(df, sbp = "blood pressure was measured by trained personnel" ) build_meta(df)
#> $data #> # A tibble: 2 x 8 #> variable label type unit group abbr note labels #> <chr> <chr> <chr> <chr> <chr> <list> <list> <list> #> 1 gfr Estimated GFR numeric mL/min/1.73 m2 None <chr [2~ <chr [1~ <chr [1~ #> 2 sbp Systolic BP numeric mm Hg None <chr [1~ <chr [1~ <chr [1~ #> #> $group_levels #> NULL #> #> $var_levels #> NULL #> #> $add_perc_to_cats #> [1] TRUE #> #> attr(,"class") #> [1] "meta"