-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget-variables.R
32 lines (30 loc) · 954 Bytes
/
get-variables.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#' Get a list of the registers' abbreviations.
#'
#' @return A character string.
#' @keywords internal
#'
#' @examples
#' get_register_abbrev()
get_register_abbrev <- function() {
unique(variable_description$register_abbrev)
}
#' Get a list of required variables from a specific register.
#'
#' @param register The abbreviation of the register name. See list of
#' abbreviations in [get_register_abbrev()].
#'
#' @return A character vector of variable names.
#' @keywords internal
#'
#' @examples
#' get_required_variables("bef")
get_required_variables <- function(register) {
if (!checkmate::test_scalar(register)) {
cli::cli_abort("You are giving too many registers, please give only one.")
}
checkmate::assert_choice(register, get_register_abbrev())
register <- rlang::arg_match(register, get_register_abbrev())
variable_description |>
dplyr::filter(.data$register_abbrev == register) |>
dplyr::pull(.data$variable_name)
}