Skip to content

Commit

Permalink
#216 admiral_0_11_update: fix lintr and R-CMD check
Browse files Browse the repository at this point in the history
  • Loading branch information
bundfussr committed Jun 1, 2023
1 parent 5579e71 commit 0cc661c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 31 deletions.
6 changes: 5 additions & 1 deletion R/derive_param_clinbenefit.R
Expand Up @@ -224,7 +224,11 @@ derive_param_clinbenefit <- function(dataset,
assert_character_vector(clinben_vals)

if (!missing(aval_fun)) {
deprecate_warn("0.4.0", "derive_param_clinbenefit(aval_fun = )", "derive_param_clinbenefit(set_values_to = )")
deprecate_warn(
"0.4.0",
"derive_param_clinbenefit(aval_fun = )",
"derive_param_clinbenefit(set_values_to = )"
)
assert_function(aval_fun)
set_values_to <- exprs(!!!set_values_to, AVAL = {{aval_fun}}(AVALC))
}
Expand Down
6 changes: 5 additions & 1 deletion R/derive_param_response.R
Expand Up @@ -193,7 +193,11 @@ derive_param_response <- function(dataset,
}

if (!missing(aval_fun)) {
deprecate_warn("0.4.0", "derive_param_response(aval_fun = )", "derive_param_response(set_values_to = )")
deprecate_warn(
"0.4.0",
"derive_param_response(aval_fun = )",
"derive_param_response(set_values_to = )"
)
set_values_to <- exprs(!!!set_values_to, AVAL = {{aval_fun}}(AVALC))
}

Expand Down
2 changes: 1 addition & 1 deletion inst/templates/ad_adrs.R
Expand Up @@ -332,7 +332,7 @@ adslmdis <- adsl %>%

adrs <- adrs %>%
derive_param_exist_flag(
dataset_adsl = adslmdis,
dataset_ref = adslmdis,
dataset_add = tu,
condition = TUEVAL == "INVESTIGATOR" & TUSTRESC == "TARGET" & VISIT == "BASELINE",
false_value = "N",
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-derive_param_response.R
Expand Up @@ -67,7 +67,7 @@ test_that("derive_param_response Test 1: With source_pd", {
source_pd = pd,
source_datasets = list(adrs = adrs),
set_values_to = exprs(
AVAL = yn_to_numeric(AVALC),
AVAL = admiral::yn_to_numeric(AVALC),
PARAMCD = "RSP",
PARAM = "Response by investigator"
),
Expand Down Expand Up @@ -109,7 +109,7 @@ test_that("derive_param_response Test 2: No source_pd", {
source_pd = NULL,
source_datasets = NULL,
set_values_to = exprs(
AVAL = yn_to_numeric(AVALC),
AVAL = admiral::yn_to_numeric(AVALC),
PARAMCD = "RSP",
PARAM = "Response by investigator"
),
Expand Down Expand Up @@ -151,7 +151,7 @@ test_that("derive_param_response Test 3: deprecation warning for aval_fun", {
filter_source = PARAMCD == "OVR" & AVALC %in% c("CR", "PR"),
source_pd = NULL,
source_datasets = NULL,
aval_fun = yn_to_numeric,
aval_fun = admiral::yn_to_numeric,
set_values_to = exprs(
PARAMCD = "RSP",
PARAM = "Response by investigator"
Expand Down
27 changes: 2 additions & 25 deletions vignettes/adrs.Rmd
Expand Up @@ -792,7 +792,7 @@ adslmdis <- adsl %>%
adrs <- adrs %>%
derive_param_exist_flag(
dataset_adsl = adslmdis,
dataset_ref = adslmdis,
dataset_add = tu,
condition = TUEVAL == "INVESTIGATOR" & TUSTRESC == "TARGET" & VISIT == "BASELINE",
false_value = "N",
Expand All @@ -802,6 +802,7 @@ adrs <- adrs %>%
PARAM = "Measurable Disease at Baseline by Investigator",
PARCAT2 = "Investigator",
PARCAT3 = "Recist 1.1",
AVAL = yn_to_numeric(AVALC),
ANL01FL = "Y"
)
)
Expand All @@ -815,30 +816,6 @@ dataset_vignette(
)
```

## Derive `AVAL` for New Parameters {#aval}

For cases where `AVALC` has been derived for new parameters above as `"Y"` or `"N"`,
we need to set `AVAL` to numeric versions such as `1`/`0`.

```{r eval=TRUE}
adrs <- adrs %>%
mutate(
AVAL = case_when(
AVALC == "Y" ~ 1,
AVALC == "N" ~ 0,
TRUE ~ AVAL
)
)
```

```{r, eval=TRUE, echo=FALSE}
dataset_vignette(
adrs,
display_vars = exprs(USUBJID, PARAMCD, AVALC, AVAL),
filter = USUBJID == "01-701-1015" & AVALC %in% c("Y", "N")
)
```

## Assign `ASEQ` {#aseq}

The function `admiral::derive_var_obs_number()` can be used to derive
Expand Down

0 comments on commit 0cc661c

Please sign in to comment.