Add variable attributes to an ARD data frame.
The
labelattribute 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
classattribute will also be returned for all columns.Any other attribute returned by
attributes()will also be added, e.g. factor levels.
Usage
# S3 method for class 'survey.design'
ard_attributes(data, variables = everything(), label = NULL, ...)Arguments
- data
(
survey.design)
a design object often created withsurvey::svydesign().- variables
(
tidy-select)
variables to include- label
(named
list)
named list of variable labels, e.g.list(cyl = "No. Cylinders"). Default isNULL- ...
These dots are for future extensions and must be empty.
Examples
data(api, package = "survey")
dclus1 <- survey::svydesign(id = ~dnum, weights = ~pw, data = apiclus1, fpc = ~fpc)
ard_attributes(
data = dclus1,
variables = c(sname, dname),
label = list(sname = "School Name", dname = "District Name")
)
#> # 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 sname attributes label Variable Label School Na… <fn> <NULL> <NULL>
#> 2 sname attributes class Variable Class character <NULL> <NULL> <NULL>
#> 3 dname attributes label Variable Label District … <fn> <NULL> <NULL>
#> 4 dname attributes class Variable Class character <NULL> <NULL> <NULL>
