Skip to content

Commit

Permalink
recid and partnership filter
Browse files Browse the repository at this point in the history
allow for recid and partnership filter when they are not specified to select in columns
  • Loading branch information
lizihao-anu committed Aug 6, 2024
1 parent a4453fe commit 787aa1d
Showing 1 changed file with 33 additions and 20 deletions.
53 changes: 33 additions & 20 deletions R/read_slf.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,13 @@ read_slf <- function(
stringr::coll("hscp2018"),
negate = TRUE
)) {
col_select <- c(col_select, "hscp2018")

remove_partnership_var <- TRUE
}
if (!is.null(recids) && file_version == "episode" &&
stringr::str_detect(rlang::quo_text(rlang::enquo(col_select)),
stringr::coll("recid"),
negate = TRUE
)) {
col_select <- c(col_select, "recid")

remove_recid_var <- TRUE
}
}
Expand All @@ -83,23 +79,40 @@ read_slf <- function(
as_data_frame = FALSE
)

if (!is.null(recids)) {
slf_table <- dplyr::filter(
slf_table,
.data$recid %in% recids
)
}
if (!is.null(partnerships)) {
slf_table <- dplyr::filter(
slf_table,
.data$hscp2018 %in% partnerships
)
if(!is.null(partnerships)){
if(remove_partnership_var){
slf_table <- cbind(
slf_table,
arrow::read_parquet(
file = file_path,
col_select = "hscp2018",
as_data_frame = FALSE
)
)
}
slf_table <- dplyr::filter(slf_table,
.data$hscp2018 %in% partnerships)
if(remove_partnership_var){
slf_table <- dplyr::select(slf_table, -"hscp2018")
}
}
if (remove_partnership_var) {
slf_table <- dplyr::select(slf_table, -"hscp2018")
}
if (remove_recid_var) {
slf_table <- dplyr::select(slf_table, -"recid")

if (!is.null(recids)) {
if (remove_recid_var) {
slf_table <- cbind(
slf_table,
arrow::read_parquet(
file = file_path,
col_select = "recid",
as_data_frame = FALSE
)
)
}
slf_table <- dplyr::filter(slf_table,
.data$recid %in% recids)
if (remove_recid_var) {
slf_table <- dplyr::select(slf_table, -"recid")
}
}

return(slf_table)
Expand Down

0 comments on commit 787aa1d

Please sign in to comment.