From 286a50edefd35ed43f9f4347a4068ac5073024f6 Mon Sep 17 00:00:00 2001 From: Ethan Brockmann <59264453+EeethB@users.noreply.github.com> Date: Fri, 8 Mar 2024 08:55:20 -0600 Subject: [PATCH] Closes #174 Specify domain filtering uses environment domain variable (#256) * Specify domain filtering uses environment domain variable * Update NEWS * Fix spelling --- NEWS.md | 4 ++++ R/df_label.R | 2 +- R/format.R | 2 +- R/label.R | 2 +- R/length.R | 2 +- R/order.R | 2 +- R/type.R | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 0e15e990..3d6dd558 100644 --- a/NEWS.md +++ b/NEWS.md @@ -6,6 +6,10 @@ * All `xportr` functions now have `verbose = NULL` as the default (#151) +* Bug fix for domain filtering (#137) + +## Documentation + * Remove unused packages from Suggests (#221) * `xportr_write()` now accepts `metadata` argument which can be used to set the dataset label to stay consistent with the other `xportr_*` functions. It is noteworthy that the dataset label set using the `xportr_df_label()` function will be retained during the `xportr_write()`. diff --git a/R/df_label.R b/R/df_label.R index 81a115ec..251ada59 100644 --- a/R/df_label.R +++ b/R/df_label.R @@ -70,7 +70,7 @@ xportr_df_label <- function(.df, if (inherits(metadata, "Metacore")) metadata <- metadata$ds_spec label <- metadata %>% - filter(!!sym(domain_name) == domain) %>% + filter(!!sym(domain_name) == .env$domain) %>% select(!!sym(label_name)) %>% # If a dataframe is used this will also be a dataframe, change to character. as.character() diff --git a/R/format.R b/R/format.R index f0abcca6..f1b05900 100644 --- a/R/format.R +++ b/R/format.R @@ -140,7 +140,7 @@ xportr_format <- function(.df, if (domain_name %in% names(metadata) && !is.null(domain)) { metadata <- metadata %>% - filter(!!sym(domain_name) == domain & !is.na(!!sym(format_name))) + filter(!!sym(domain_name) == .env$domain & !is.na(!!sym(format_name))) } else { # Common check for multiple variables name check_multiple_var_specs(metadata, variable_name) diff --git a/R/label.R b/R/label.R index 113d216e..3d70464e 100644 --- a/R/label.R +++ b/R/label.R @@ -97,7 +97,7 @@ xportr_label <- function(.df, if (domain_name %in% names(metadata) && !is.null(domain)) { metadata <- metadata %>% - dplyr::filter(!!sym(domain_name) == domain) + dplyr::filter(!!sym(domain_name) == .env$domain) } else { # Common check for multiple variables name check_multiple_var_specs(metadata, variable_name) diff --git a/R/length.R b/R/length.R index 33a98394..f6281d19 100644 --- a/R/length.R +++ b/R/length.R @@ -106,7 +106,7 @@ xportr_length <- function(.df, if (domain_name %in% names(metadata) && !is.null(domain)) { metadata <- metadata %>% - filter(!!sym(domain_name) == domain) + filter(!!sym(domain_name) == .env$domain) } else { # Common check for multiple variables name check_multiple_var_specs(metadata, variable_name) diff --git a/R/order.R b/R/order.R index 39b4d528..03ebba0f 100644 --- a/R/order.R +++ b/R/order.R @@ -100,7 +100,7 @@ xportr_order <- function(.df, if (domain_name %in% names(metadata) && !is.null(domain)) { metadata <- metadata %>% - dplyr::filter(!!sym(domain_name) == domain & !is.na(!!sym(order_name))) + dplyr::filter(!!sym(domain_name) == .env$domain & !is.na(!!sym(order_name))) } else { metadata <- metadata %>% dplyr::filter(!is.na(!!sym(order_name))) diff --git a/R/type.R b/R/type.R index d02c3bfa..6ad58c2c 100644 --- a/R/type.R +++ b/R/type.R @@ -113,7 +113,7 @@ xportr_type <- function(.df, if (domain_name %in% names(metadata) && !is.null(domain)) { metadata <- metadata %>% - filter(!!sym(domain_name) == domain) + filter(!!sym(domain_name) == .env$domain) } metacore <- metadata %>%