-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#' ARD Attributes | ||
#' | ||
#' @description | ||
#' 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. | ||
#' | ||
#' @rdname ard_attributes | ||
#' @param data (`survey.design`)\cr | ||
#' a design object often created with [`survey::svydesign()`]. | ||
#' @param variables ([`tidy-select`][dplyr::dplyr_tidy_select])\cr | ||
#' variables to include | ||
#' @param label (named `list`)\cr | ||
#' named list of variable labels, e.g. `list(cyl = "No. Cylinders")`. | ||
#' Default is `NULL` | ||
#' @inheritParams rlang::args_dots_empty | ||
#' | ||
#' @return an ARD data frame of class 'card' | ||
#' @export | ||
#' | ||
#' @examplesIf do.call(asNamespace("cardx")$is_pkg_installed, list(pkg = "survey", reference_pkg = "cardx")) | ||
#' 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") | ||
#' ) | ||
ard_attributes.survey.design <- function(data, variables = everything(), label = NULL, ...) { | ||
set_cli_abort_call() | ||
|
||
cards::ard_attributes(data = data[["variables"]], variables = {{ variables }}, label = label, ...) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.