Add variable attributes to an ARD data frame.
The label attribute will be added for all columns, and when no label
is specified and no label has been set for a column using the label= argument,
the column name will be placed in the label statistic.
The class attribute will also be returned for all columns.
Any other attribute returned by attributes() will also be added, e.g. factor levels.
ard_attributes(data, ...)
# S3 method for class 'data.frame'
ard_attributes(data, variables = everything(), label = NULL, ...)
# Default S3 method
ard_attributes(data, ...)(data.frame)
a data frame
These dots are for future extensions and must be empty.
(tidy-select)
variables to include
(named list)
named list of variable labels, e.g. list(cyl = "No. Cylinders").
Default is NULL
an ARD data frame of class 'card'
df <- dplyr::tibble(var1 = letters, var2 = LETTERS)
attr(df$var1, "label") <- "Lowercase Letters"
ard_attributes(df, variables = everything())
#> # An ARD data frame: 4 × 8
#> variable context stat_name stat_label stat fmt_fun warning error
#> * <chr> <chr> <chr> <chr> <list> <list> <list> <list>
#> 1 var1 attributes label Variable Label Lowercase… <fn> <NULL> <NULL>
#> 2 var1 attributes class Variable Class character <NULL> <NULL> <NULL>
#> 3 var2 attributes label Variable Label var2 <fn> <NULL> <NULL>
#> 4 var2 attributes class Variable Class character <NULL> <NULL> <NULL>