diff --git a/R/derive_params_growth_age.R b/R/derive_params_growth_age.R index 2af72b2..be6a0a9 100644 --- a/R/derive_params_growth_age.R +++ b/R/derive_params_growth_age.R @@ -244,6 +244,7 @@ derive_params_growth_age <- function(dataset, # create a unified join naming convention, hard to figure out in by argument dataset2 <- dataset %>% + filter(!!enexpr(parameter)) %>% mutate( sex_join := {{ sex }}, ageu_join := {{ age_unit }}, @@ -272,7 +273,6 @@ derive_params_growth_age <- function(dataset, # Merge the dataset that contains the vs records and filter the L/M/S that fit the appropriate age added_records <- dataset2 %>% - filter(!!enexpr(parameter)) %>% left_join(., processed_md, by = c("sex_join", "ageu_join", "age_bins") @@ -281,7 +281,8 @@ derive_params_growth_age <- function(dataset, by_exprs <- enexpr(by_vars) by_antijoin <- setNames(as.character(by_exprs), as.character(by_exprs)) - unmatched_records <- anti_join(dataset, added_records, by = by_antijoin) + unmatched_records <- anti_join(dataset, added_records, by = by_antijoin) %>% + filter(!!enexpr(parameter)) dataset_final <- dataset diff --git a/R/derive_params_growth_height.R b/R/derive_params_growth_height.R index 8d10f7b..c6f7b51 100644 --- a/R/derive_params_growth_height.R +++ b/R/derive_params_growth_height.R @@ -230,7 +230,8 @@ derive_params_growth_height <- function(dataset, bins <- get_bins(meta_criteria, param = "HEIGHT_LENGTH") # create a unified join naming convention, hard to figure out in by argument - dataset <- dataset %>% + dataset2 <- dataset %>% + filter(!!enexpr(parameter)) %>% mutate( sex_join := {{ sex }}, heightu_join := {{ height_unit }}, @@ -258,8 +259,7 @@ derive_params_growth_height <- function(dataset, ) # Merge the dataset that contains the vs records and filter the L/M/S that match height - added_records <- dataset %>% - filter(!!enexpr(parameter)) %>% + added_records <- dataset2 %>% left_join(., processed_md, by = c("sex_join", "heightu_join", "ht_bins") @@ -268,7 +268,8 @@ derive_params_growth_height <- function(dataset, by_exprs <- enexpr(by_vars) by_antijoin <- setNames(as.character(by_exprs), as.character(by_exprs)) - unmatched_records <- anti_join(dataset, added_records, by = by_antijoin) + unmatched_records <- anti_join(dataset, added_records, by = by_antijoin) %>% + filter(!!enexpr(parameter)) dataset_final <- dataset