Skip to content

Commit

Permalink
feat: #54 align terminology in data with get_terms() function (#55)
Browse files Browse the repository at this point in the history
Co-authored-by: Zelos Zhu <[email protected]>
  • Loading branch information
zdz2101 and Zelos Zhu authored Aug 22, 2023
1 parent 66789a2 commit 8061842
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions R/get_terms.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ get_terms <- function(basket_select,
keep_id,
temp_env) {
if (basket_select$type == "smq") {
if (is.null(temp_env$admiral_smq_db)) {
data("admiral_smq_db", envir = temp_env)
if (is.null(temp_env$smq_db)) {
data("smq_db", envir = temp_env)
}
if (!is.null(basket_select$name)) {
is_in_smq <- temp_env$admiral_smq_db$smq_name == basket_select$name
is_in_smq <- temp_env$smq_db$smq_name == basket_select$name
} else {
is_in_smq <- temp_env$admiral_smq_db$smq_id == basket_select$id
is_in_smq <- temp_env$smq_db$smq_id == basket_select$id
}
if (basket_select$scope == "NARROW") {
is_in_scope <- temp_env$admiral_smq_db$scope == "narrow"
is_in_scope <- temp_env$smq_db$scope == "narrow"
} else {
is_in_scope <- rep(TRUE, nrow(temp_env$admiral_smq_db))
is_in_scope <- rep(TRUE, nrow(temp_env$smq_db))
}
if (keep_id) {
select_id <- c(GRPID = "smq_id")
Expand All @@ -39,17 +39,17 @@ get_terms <- function(basket_select,
)

structure(
temp_env$admiral_smq_db[is_in_smq & is_in_scope, keep_cols],
temp_env$smq_db[is_in_smq & is_in_scope, keep_cols],
names = names(keep_cols)
)
} else if (basket_select$type == "sdg") {
if (is.null(temp_env$admiral_sdg_db)) {
data("admiral_sdg_db", envir = temp_env)
if (is.null(temp_env$sdg_db)) {
data("sdg_db", envir = temp_env)
}
if (!is.null(basket_select$name)) {
is_in_sdq <- temp_env$admiral_sdg_db$sdg_name == basket_select$name
is_in_sdq <- temp_env$sdg_db$sdg_name == basket_select$name
} else {
is_in_sdq <- temp_env$admiral_sdg_db$sdg_id == basket_select$id
is_in_sdq <- temp_env$sdg_db$sdg_id == basket_select$id
}
if (keep_id) {
select_id <- c(GRPID = "sdg_id")
Expand All @@ -64,7 +64,7 @@ get_terms <- function(basket_select,
)

structure(
temp_env$admiral_sdg_db[is_in_sdq, keep_cols],
temp_env$sdg_db[is_in_sdq, keep_cols],
names = names(keep_cols)
)
}
Expand Down

0 comments on commit 8061842

Please sign in to comment.