Skip to content

Commit

Permalink
Revert "replace nested ifelse with case when per lintr suggestion"
Browse files Browse the repository at this point in the history
This reverts commit f6d467b.
  • Loading branch information
Rosemary Li committed Feb 12, 2024
1 parent f6d467b commit 9ad8daf
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions R/calculate_study_day.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,20 @@ calculate_study_day <- function(sdtm_in,
}
)

sdtm_in <- sdtm_in |> dplyr::mutate(
{{ study_day_var }} := dplyr::case_when(
{{ refdt_vector }} <= {{ tgdt_vector }} ~ {{ refdt_vector }} - {{ tgdt_vector }} + 1,
{{ refdt_vector }} > {{ tgdt_vector }} ~ {{ tgdt_vector }} - {{ refdt_vector }},
.default = NA
refdt_vector <- sdtm_in[[refdt]]
tgdt_vector <- sdtm_in[[tgdt]]

res <- ifelse(
test = refdt_vector <= tgdt_vector,
yes = refdt_vector - tgdt_vector + 1L,
no = ifelse(
test = refdt_vector > tgdt_vector,
yes = tgdt_vector - refdt_vector,
no = NA
)
)

sdtm_in <- sdtm_in[c(original_variables, study_day_var)]
sdtm_in <- sdtm_in[original_variables]
sdtm_in[study_day_var] <- res
return(sdtm_in)
}

0 comments on commit 9ad8daf

Please sign in to comment.