Skip to content

Commit

Permalink
#256 admiral_updates: fix flagging of worst
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Dec 12, 2023
1 parent a4c655e commit e8b5b7f
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
14 changes: 13 additions & 1 deletion inst/templates/ad_adrs.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,24 @@ adrs <- adrs %>%
# parameter derivations - here only valid assessments and those occurring on or
# after randomization date, if there is more than one assessment per date the
# worst one is flagged
worst_resp <- function(arg) {
case_when(
arg == "CR" ~ 1,
arg == "PR" ~ 2,
arg == "SD" ~ 3,
arg == "NON-CR/NON-PD" ~ 4,
arg == "NE" ~ 5,
arg == "PD" ~ 6,
TRUE ~ 0
)
}

adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
order = exprs(AVAL, RSSEQ),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
),
Expand Down
14 changes: 13 additions & 1 deletion inst/templates/ad_adrs_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,24 @@ adrs <- adrs %>%
# parameter derivations - here only valid assessments and those occurring on or
# after randomization date, if there is more than one assessment per date the
# worst one is flagged
worst_resp <- function(arg) {
case_when(
arg == "CR" ~ 1,
arg == "PR" ~ 2,
arg == "SD" ~ 3,
arg == "NON-CR/NON-PD" ~ 4,
arg == "NE" ~ 5,
arg == "PD" ~ 6,
TRUE ~ 0
)
}

adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
order = exprs(AVAL, RSSEQ),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
),
Expand Down
16 changes: 14 additions & 2 deletions vignettes/adrs.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,24 @@ those occurring on or after randomization date. If there is more than
one assessment at a date, the worst one is flagged.

```{r}
worst_resp <- function(arg) {
case_when(
arg == "CR" ~ 1,
arg == "PR" ~ 2,
arg == "SD" ~ 3,
arg == "NON-CR/NON-PD" ~ 4,
arg == "NE" ~ 5,
arg == "PD" ~ 6,
TRUE ~ 0
)
}
adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
order = exprs(AVAL, RSSEQ),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
),
Expand Down Expand Up @@ -492,7 +504,7 @@ rsp_y
adrs <- adrs %>%
derive_extreme_event(
by_vars = exprs(STUDYID, USUBJID),
order = exprs(ADT, event_nr),
order = exprs(event_nr, ADT),
tmp_event_nr_var = event_nr,
mode = "first",
events = list(rsp_y, no_data_n),
Expand Down
14 changes: 13 additions & 1 deletion vignettes/adrs_basic.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,24 @@ those occurring on or after randomization date. If there is more than
one assessment at a date, the worst one is flagged.

```{r}
worst_resp <- function(arg) {
case_when(
arg == "CR" ~ 1,
arg == "PR" ~ 2,
arg == "SD" ~ 3,
arg == "NON-CR/NON-PD" ~ 4,
arg == "NE" ~ 5,
arg == "PD" ~ 6,
TRUE ~ 0
)
}
adrs <- adrs %>%
restrict_derivation(
derivation = derive_var_extreme_flag,
args = params(
by_vars = exprs(STUDYID, USUBJID, ADT),
order = exprs(AVAL, RSSEQ),
order = exprs(worst_resp(AVALC), RSSEQ),
new_var = ANL01FL,
mode = "last"
),
Expand Down

0 comments on commit e8b5b7f

Please sign in to comment.