Skip to content

Commit

Permalink
Apply review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiyuC committed Sep 23, 2024
1 parent 31aadcd commit 796cc3f
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions R/derive_blfl.R
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,9 @@ derive_blfl <- function(sdtm_in,

# Filter out rows where --ORRES is missing. Filter out --ORRES in
# ("ND", "NOT DONE") as well.
bad_orres_rows <- is.na(ds_mod[[domain_prefixed_names["orres"]]]) |
trimws(ds_mod[[domain_prefixed_names["orres"]]]) %in% c("ND", "NOT DONE", "")
ds_mod <- ds_mod[!bad_orres_rows, ]
ds_mod <- ds_mod |>
dplyr::filter(!(is.na(.data[[domain_prefixed_names["orres"]]]) |
trimws(.data[[domain_prefixed_names["orres"]]]) %in% c("ND", "NOT DONE", "")))

# Filter out rows where --STAT is not equal to "NOT DONE"
ds_mod <-
Expand All @@ -374,10 +374,10 @@ derive_blfl <- function(sdtm_in,
}

# Checking for columns of interest
con_col <- c(domain_prefixed_names[c("testcd", "dtc", "var_tpt")], "VISIT")
con_col <- c(domain_prefixed_names[c("testcd", "dtc", "tpt")], "VISIT")

# Drop those columns from the list which are not present in ds_in
con_col <- con_col[con_col %in% names(sdtm_in)]
# Drop those columns from the list which are not present in ds_mod
con_col <- con_col[con_col %in% names(ds_mod)]

# Check for any column which is all NA and removing it from con_col list
h <- which(sapply(ds_mod, function(x) all(is.na(x))))
Expand Down Expand Up @@ -438,16 +438,17 @@ derive_blfl <- function(sdtm_in,
dplyr::filter(
dom_dt == ref_dt,
is.na(dom_tm) | is.na(ref_tm) | dom_tm == ref_tm,
(VISIT %in% baseline_visits & get(domain_prefixed_names["tpt"]) %in% baseline_timepoints) |
(VISIT %in% baseline_visits & !!rlang::sym(domain_prefixed_names["tpt"]) %in% baseline_timepoints) |
(VISIT %in% baseline_visits & length(baseline_timepoints) == 0L) |
(get(domain_prefixed_names["tpt"]) %in% baseline_timepoints & length(baseline_visits) == 0L)
(!!rlang::sym(domain_prefixed_names["tpt"]) %in% baseline_timepoints & length(baseline_visits) == 0L)
)

# Combine (*A) and (*B) and (*C)
ds_base <- rbind(ds_subset_lt, ds_subset_eq_1, ds_subset_eq_2)
ds_base <- dplyr::bind_rows(ds_subset_lt, ds_subset_eq_1, ds_subset_eq_2)

# Sort the rows in ascending order with respect to columns from con_col
ds_base <- dplyr::arrange_at(ds_base, c("USUBJID", con_col))
ds_base <- ds_base |>
dplyr::arrange(USUBJID, !!!rlang::syms(con_col))

if (nrow(ds_base) == 0L) {
cli::cli_inform("There are no baseline records.")
Expand Down

0 comments on commit 796cc3f

Please sign in to comment.