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 thelabel=
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.
Usage
ard_attributes(data, ...)
# S3 method for class 'data.frame'
ard_attributes(data, variables = everything(), label = NULL, ...)
# Default S3 method
ard_attributes(data, ...)
Arguments
- data
(
data.frame
)
a data frame- ...
These dots are for future extensions and must be empty.
- variables
(
tidy-select
)
variables to include- label
(named
list
)
named list of variable labels, e.g.list(cyl = "No. Cylinders")
. Default isNULL
Examples
df <- dplyr::tibble(var1 = letters, var2 = LETTERS)
attr(df$var1, "label") <- "Lowercase Letters"
ard_attributes(df, variables = everything())
#> {cards} data frame: 4 x 5
#> variable context stat_name stat_label stat
#> 1 var1 attribut… label Variable… Lowercas…
#> 2 var1 attribut… class Variable… character
#> 3 var2 attribut… label Variable… var2
#> 4 var2 attribut… class Variable… character