Skip to content

Commit

Permalink
Closes #174 Specify domain filtering uses environment domain variable (
Browse files Browse the repository at this point in the history
…#256)

* Specify domain filtering uses environment domain variable

* Update NEWS

* Fix spelling
  • Loading branch information
EeethB committed Mar 8, 2024
1 parent 0a88eea commit 286a50e
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 6 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
Expand Down
2 changes: 1 addition & 1 deletion R/df_label.R
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion R/format.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/label.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/length.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion R/order.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
Expand Down
2 changes: 1 addition & 1 deletion R/type.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>%
Expand Down

0 comments on commit 286a50e

Please sign in to comment.