Skip to content

Commit

Permalink
Updated other ABLFL so that the blanks are NA_charater_
Browse files Browse the repository at this point in the history
  • Loading branch information
sadchla-codes committed Nov 21, 2024
1 parent 92e68d7 commit 9206460
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 143 deletions.
6 changes: 3 additions & 3 deletions R/derive_var_shift.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@
#' data <- tribble(
#' ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BNRIND, ~ANRIND,
#' "P01", "ALB", 33, "Y", "LOW", "LOW",
#' "P01", "ALB", 38, NA, "LOW", "NORMAL",
#' "P01", "ALB", NA, NA, "LOW", NA,
#' "P01", "ALB", 38, NA_character_, "LOW", "NORMAL",
#' "P01", "ALB", NA, NA_character_, "LOW", NA,
#' "P02", "ALB", 37, "Y", "NORMAL", "NORMAL",
#' "P02", "ALB", 49, NA, "NORMAL", "HIGH",
#' "P02", "ALB", 49, NA_character_, "NORMAL", "HIGH",
#' "P02", "SODIUM", 147, "Y", "HIGH", "HIGH"
#' )
#'
Expand Down
16 changes: 8 additions & 8 deletions R/derive_vars_computed.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@
#' advs <- tribble(
#' ~STUDYID, ~USUBJID, ~PARAMCD, ~PARAM, ~VISIT, ~AVAL, ~AVALU, ~ABLFL,
#' "PILOT01", "01-1302", "HEIGHT", "Height (cm)", "SCREENING", 177.8, "cm", "Y",
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "SCREENING", 81.19, "kg", "N",
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "SCREENING", 81.19, "kg", NA_character_,
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "BASELINE", 82.1, "kg", "Y",
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "WEEK 2", 81.19, "kg", "N",
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "WEEK 4", 82.56, "kg", "N",
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "WEEK 6", 80.74, "kg", "N",
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "WEEK 2", 81.19, "kg", NA_character_,
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "WEEK 4", 82.56, "kg", NA_character_,
#' "PILOT01", "01-1302", "WEIGHT", "Weight (kg)", "WEEK 6", 80.74, "kg", NA_character_,
#' "PILOT01", "17-1344", "HEIGHT", "Height (cm)", "SCREENING", 163.5, "cm", "Y",
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "SCREENING", 58.06, "kg", "N",
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "SCREENING", 58.06, "kg", NA_character_,
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "BASELINE", 58.06, "kg", "Y",
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "WEEK 2", 58.97, "kg", "N",
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "WEEK 4", 57.97, "kg", "N",
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "WEEK 6", 58.97, "kg", "N"
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "WEEK 2", 58.97, "kg", NA_character_,
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "WEEK 4", 57.97, "kg", NA_character_,
#' "PILOT01", "17-1344", "WEIGHT", "Weight (kg)", "WEEK 6", 58.97, "kg", NA_character_
#' )
#'
#' derive_vars_computed(
Expand Down
6 changes: 3 additions & 3 deletions man/derive_var_shift.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions man/derive_vars_computed.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 37 additions & 37 deletions tests/testthat/test-derive_var_base.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@ test_that("derive_var_base Test 1: `target` is set to `source` where `ABLFL == '
input <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~ASEQ, ~AVAL, ~ABLFL, ~BASETYPE,
"TEST01", "PAT01", "PARAM01", 1, 10.12, "Y", "LAST",
"TEST01", "PAT01", "PARAM01", 2, 9.7, "", "LAST",
"TEST01", "PAT01", "PARAM01", 3, 15.01, "", "LAST",
"TEST01", "PAT01", "PARAM01", 2, 9.7, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM01", 3, 15.01, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM02", 1, 8.35, "Y", "LAST",
"TEST01", "PAT01", "PARAM02", 2, NA, "", "LAST",
"TEST01", "PAT01", "PARAM02", 3, 8.35, "", "LAST",
"TEST01", "PAT01", "PARAM02", 2, NA, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM02", 3, 8.35, NA_character_, "LAST",
"TEST01", "PAT02", "PARAM01", 1, 29, "Y", "LAST",
"TEST01", "PAT02", "PARAM01", 2, 19.7, "", "LAST",
"TEST01", "PAT02", "PARAM01", 3, 18.01, "", "LAST",
"TEST01", "PAT02", "PARAM01", 2, 19.7, NA_character_, "LAST",
"TEST01", "PAT02", "PARAM01", 3, 18.01, NA_character_, "LAST",
"TEST01", "PAT02", "PARAM02", 1, 8.9, "Y", "LAST",
"TEST01", "PAT02", "PARAM02", 2, 9, "", "LAST",
"TEST01", "PAT02", "PARAM02", 3, 5.35, "", "LAST"
"TEST01", "PAT02", "PARAM02", 2, 9, NA_character_, "LAST",
"TEST01", "PAT02", "PARAM02", 3, 5.35, NA_character_, "LAST"
)
expected_output <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~ASEQ, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE,
"TEST01", "PAT01", "PARAM01", 1, 10.12, "Y", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 2, 9.7, "", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 3, 15.01, "", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 2, 9.7, NA_character_, "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 3, 15.01, NA_character_, "LAST", 10.12,
"TEST01", "PAT01", "PARAM02", 1, 8.35, "Y", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 2, NA, "", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 3, 8.35, "", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 2, NA, NA_character_, "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 3, 8.35, NA_character_, "LAST", 8.35,
"TEST01", "PAT02", "PARAM01", 1, 29, "Y", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 2, 19.7, "", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 3, 18.01, "", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 2, 19.7, NA_character_, "LAST", 29,
"TEST01", "PAT02", "PARAM01", 3, 18.01, NA_character_, "LAST", 29,
"TEST01", "PAT02", "PARAM02", 1, 8.9, "Y", "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 2, 9, "", "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 3, 5.35, "", "LAST", 8.9
"TEST01", "PAT02", "PARAM02", 2, 9, NA_character_, "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 3, 5.35, NA_character_, "LAST", 8.9
)
actual_output <- derive_var_base(
input,
Expand All @@ -49,20 +49,20 @@ test_that("derive_var_base Test 2: `target` is set to `NA` if a baseline record
input <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~ASEQ, ~AVAL, ~ABLFL, ~BASETYPE,
"TEST01", "PAT01", "PARAM01", 1, 10.12, "Y", "LAST",
"TEST01", "PAT01", "PARAM01", 2, 9.7, "", "LAST",
"TEST01", "PAT01", "PARAM01", 3, 15.01, "", "LAST",
"TEST01", "PAT01", "PARAM02", 1, 4.9, "", "LAST",
"TEST01", "PAT01", "PARAM02", 2, 7.1, "", "LAST",
"TEST01", "PAT01", "PARAM02", 3, 8.35, "", "LAST"
"TEST01", "PAT01", "PARAM01", 2, 9.7, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM01", 3, 15.01, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM02", 1, 4.9, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM02", 2, 7.1, NA_character_, "LAST",
"TEST01", "PAT01", "PARAM02", 3, 8.35, NA_character_, "LAST"
)
expected_output <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~ASEQ, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE,
"TEST01", "PAT01", "PARAM01", 1, 10.12, "Y", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 2, 9.7, "", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 3, 15.01, "", "LAST", 10.12,
"TEST01", "PAT01", "PARAM02", 1, 4.9, "", "LAST", NA,
"TEST01", "PAT01", "PARAM02", 2, 7.1, "", "LAST", NA,
"TEST01", "PAT01", "PARAM02", 3, 8.35, "", "LAST", NA
"TEST01", "PAT01", "PARAM01", 2, 9.7, NA_character_, "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 3, 15.01, NA_character_, "LAST", 10.12,
"TEST01", "PAT01", "PARAM02", 1, 4.9, NA_character_, "LAST", NA,
"TEST01", "PAT01", "PARAM02", 2, 7.1, NA_character_, "LAST", NA,
"TEST01", "PAT01", "PARAM02", 3, 8.35, NA_character_, "LAST", NA
)
actual_output <- derive_var_base(
input,
Expand All @@ -83,20 +83,20 @@ test_that("derive_var_base Test 3: only the `target` variable is added to the in
input <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~ASEQ, ~AVAL, ~ABLFL, ~BASETYPE, ~ANL01FL,
"TEST01", "PAT01", "PARAM01", 1, 10.12, "Y", "LAST", "Y",
"TEST01", "PAT01", "PARAM01", 2, 9.7, "", "LAST", "Y",
"TEST01", "PAT01", "PARAM01", 3, 15.01, "", "LAST", "Y",
"TEST01", "PAT01", "PARAM01", 2, 9.7, NA_character_, "LAST", "Y",
"TEST01", "PAT01", "PARAM01", 3, 15.01, NA_character_, "LAST", "Y",
"TEST01", "PAT01", "PARAM02", 1, 8.35, "Y", "LAST", "Y",
"TEST01", "PAT01", "PARAM02", 2, NA, "", "LAST", "Y",
"TEST01", "PAT01", "PARAM02", 3, 8.35, "", "LAST", "Y"
"TEST01", "PAT01", "PARAM02", 2, NA, NA_character_, "LAST", "Y",
"TEST01", "PAT01", "PARAM02", 3, 8.35, NA_character_, "LAST", "Y"
)
expected_output <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~ASEQ, ~AVAL, ~ABLFL, ~BASETYPE, ~ANL01FL, ~BASE,
"TEST01", "PAT01", "PARAM01", 1, 10.12, "Y", "LAST", "Y", 10.12,
"TEST01", "PAT01", "PARAM01", 2, 9.7, "", "LAST", "Y", 10.12,
"TEST01", "PAT01", "PARAM01", 3, 15.01, "", "LAST", "Y", 10.12,
"TEST01", "PAT01", "PARAM01", 2, 9.7, NA_character_, "LAST", "Y", 10.12,
"TEST01", "PAT01", "PARAM01", 3, 15.01, NA_character_, "LAST", "Y", 10.12,
"TEST01", "PAT01", "PARAM02", 1, 8.35, "Y", "LAST", "Y", 8.35,
"TEST01", "PAT01", "PARAM02", 2, NA, "", "LAST", "Y", 8.35,
"TEST01", "PAT01", "PARAM02", 3, 8.35, "", "LAST", "Y", 8.35
"TEST01", "PAT01", "PARAM02", 2, NA, NA_character_, "LAST", "Y", 8.35,
"TEST01", "PAT01", "PARAM02", 3, 8.35, NA_character_, "LAST", "Y", 8.35
)
actual_output <- derive_var_base(
input,
Expand All @@ -118,11 +118,11 @@ test_that("derive_var_base Test 4: error if multiple baseline records", {
~STUDYID, ~USUBJID, ~PARAMCD, ~AVALC, ~ABLFL, ~BASETYPE,
"TEST01", "PAT01", "PARAM01", "LOW", "Y", "LAST",
"TEST01", "PAT01", "PARAM01", "MEDIUM", "Y", "LAST",
"TEST01", "PAT01", "PARAM01", "LOW", "", "LAST",
"TEST01", "PAT01", "PARAM01", "MEDIUM", "", "LAST",
"TEST01", "PAT01", "PARAM01", "LOW", NA_character_, "LAST",
"TEST01", "PAT01", "PARAM01", "MEDIUM", NA_character_, "LAST",
"TEST01", "PAT02", "PARAM02", "HIGH", "Y", "LAST",
"TEST01", "PAT02", "PARAM02", "HIGH", "Y", "LAST",
"TEST01", "PAT02", "PARAM02", "MEDIUM", "", "LAST",
"TEST01", "PAT02", "PARAM02", "MEDIUM", NA_character_, "LAST",
)

expect_snapshot(
Expand Down
72 changes: 36 additions & 36 deletions tests/testthat/test-derive_var_chg.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@ test_that("`CHG` is calculated as `AVAL - BASE`", {
input <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE,
"TEST01", "PAT01", "PARAM01", 10.12, "Y", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 9.7, "", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 15.01, "", "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 9.7, NA_character_, "LAST", 10.12,
"TEST01", "PAT01", "PARAM01", 15.01, NA_character_, "LAST", 10.12,
"TEST01", "PAT01", "PARAM02", 8.35, "Y", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", NA, "", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 8.35, "", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", NA, NA_character_, "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 8.35, NA_character_, "LAST", 8.35,
"TEST01", "PAT02", "PARAM01", 29, "Y", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 19.7, "", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 18.01, "", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 19.7, NA_character_, "LAST", 29,
"TEST01", "PAT02", "PARAM01", 18.01, NA_character_, "LAST", 29,
"TEST01", "PAT02", "PARAM02", 8.9, "Y", "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 9, "", "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 5.35, "", "LAST", 8.9
"TEST01", "PAT02", "PARAM02", 9, NA_character_, "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 5.35, NA_character_, "LAST", 8.9
)
expected_output <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE, ~CHG,
"TEST01", "PAT01", "PARAM01", 10.12, "Y", "LAST", 10.12, 0,
"TEST01", "PAT01", "PARAM01", 9.7, "", "LAST", 10.12, -0.42,
"TEST01", "PAT01", "PARAM01", 15.01, "", "LAST", 10.12, 4.89,
"TEST01", "PAT01", "PARAM01", 9.7, NA_character_, "LAST", 10.12, -0.42,
"TEST01", "PAT01", "PARAM01", 15.01, NA_character_, "LAST", 10.12, 4.89,
"TEST01", "PAT01", "PARAM02", 8.35, "Y", "LAST", 8.35, 0,
"TEST01", "PAT01", "PARAM02", NA, "", "LAST", 8.35, NA,
"TEST01", "PAT01", "PARAM02", 8.35, "", "LAST", 8.35, 0,
"TEST01", "PAT01", "PARAM02", NA, NA_character_, "LAST", 8.35, NA,
"TEST01", "PAT01", "PARAM02", 8.35, NA_character_, "LAST", 8.35, 0,
"TEST01", "PAT02", "PARAM01", 29, "Y", "LAST", 29, 0,
"TEST01", "PAT02", "PARAM01", 19.7, "", "LAST", 29, -9.3,
"TEST01", "PAT02", "PARAM01", 18.01, "", "LAST", 29, -10.99,
"TEST01", "PAT02", "PARAM01", 19.7, NA_character_, "LAST", 29, -9.3,
"TEST01", "PAT02", "PARAM01", 18.01, NA_character_, "LAST", 29, -10.99,
"TEST01", "PAT02", "PARAM02", 8.9, "Y", "LAST", 8.9, 0,
"TEST01", "PAT02", "PARAM02", 9, "", "LAST", 8.9, 0.1,
"TEST01", "PAT02", "PARAM02", 5.35, "", "LAST", 8.9, -3.55
"TEST01", "PAT02", "PARAM02", 9, NA_character_, "LAST", 8.9, 0.1,
"TEST01", "PAT02", "PARAM02", 5.35, NA_character_, "LAST", 8.9, -3.55
)

expect_equal(derive_var_chg(input)$CHG, expected_output$CHG)
Expand All @@ -37,33 +37,33 @@ test_that("`PCHG` is calculated as `(AVAL - BASE) / abs(BASE) * 100`", {
input <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE,
"TEST01", "PAT01", "PARAM01", -10.12, "Y", "LAST", -10.12,
"TEST01", "PAT01", "PARAM01", -9.7, "", "LAST", -10.12,
"TEST01", "PAT01", "PARAM01", -15.01, "", "LAST", -10.12,
"TEST01", "PAT01", "PARAM01", -9.7, NA_character_, "LAST", -10.12,
"TEST01", "PAT01", "PARAM01", -15.01, NA_character_, "LAST", -10.12,
"TEST01", "PAT01", "PARAM02", 8.35, "Y", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", NA, "", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 8.35, "", "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", NA, NA_character_, "LAST", 8.35,
"TEST01", "PAT01", "PARAM02", 8.35, NA_character_, "LAST", 8.35,
"TEST01", "PAT02", "PARAM01", 29, "Y", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 19.7, "", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 18.01, "", "LAST", 29,
"TEST01", "PAT02", "PARAM01", 19.7, NA_character_, "LAST", 29,
"TEST01", "PAT02", "PARAM01", 18.01, NA_character_, "LAST", 29,
"TEST01", "PAT02", "PARAM02", 8.9, "Y", "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 9, "", "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 5.35, "", "LAST", 8.9
"TEST01", "PAT02", "PARAM02", 9, NA_character_, "LAST", 8.9,
"TEST01", "PAT02", "PARAM02", 5.35, NA_character_, "LAST", 8.9
)

expected_output <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE, ~PCHG,
"TEST01", "PAT01", "PARAM01", -10.12, "Y", "LAST", -10.12, 0,
"TEST01", "PAT01", "PARAM01", -9.7, "", "LAST", -10.12, 4.150198,
"TEST01", "PAT01", "PARAM01", -15.01, "", "LAST", -10.12, -48.32016,
"TEST01", "PAT01", "PARAM01", -9.7, NA_character_, "LAST", -10.12, 4.150198,
"TEST01", "PAT01", "PARAM01", -15.01, NA_character_, "LAST", -10.12, -48.32016,
"TEST01", "PAT01", "PARAM02", 8.35, "Y", "LAST", 8.35, 0,
"TEST01", "PAT01", "PARAM02", NA, "", "LAST", 8.35, NA,
"TEST01", "PAT01", "PARAM02", 8.35, "", "LAST", 8.35, 0,
"TEST01", "PAT01", "PARAM02", NA, NA_character_, "LAST", 8.35, NA,
"TEST01", "PAT01", "PARAM02", 8.35, NA_character_, "LAST", 8.35, 0,
"TEST01", "PAT02", "PARAM01", 29, "Y", "LAST", 29, 0,
"TEST01", "PAT02", "PARAM01", 19.7, "", "LAST", 29, -32.06897,
"TEST01", "PAT02", "PARAM01", 18.01, "", "LAST", 29, -37.89655,
"TEST01", "PAT02", "PARAM01", 19.7, NA_character_, "LAST", 29, -32.06897,
"TEST01", "PAT02", "PARAM01", 18.01, NA_character_, "LAST", 29, -37.89655,
"TEST01", "PAT02", "PARAM02", 8.9, "Y", "LAST", 8.9, 0,
"TEST01", "PAT02", "PARAM02", 9, "", "LAST", 8.9, 1.123596,
"TEST01", "PAT02", "PARAM02", 5.35, "", "LAST", 8.9, -39.88764
"TEST01", "PAT02", "PARAM02", 9, NA_character_, "LAST", 8.9, 1.123596,
"TEST01", "PAT02", "PARAM02", 5.35, NA_character_, "LAST", 8.9, -39.88764
)

expect_equal(derive_var_pchg(input)$PCHG, expected_output$PCHG, tolerance = 1e-5)
Expand All @@ -73,15 +73,15 @@ test_that("`PCHG` is set to `NA` if `BASE == 0`", {
input <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE, ~CHG,
"TEST01", "PAT01", "PARAM01", 0, "Y", "LAST", 0, 0,
"TEST01", "PAT01", "PARAM01", 1.7, "", "LAST", 0, 1.7,
"TEST01", "PAT01", "PARAM01", 3.01, "", "LAST", 0, 3.01,
"TEST01", "PAT01", "PARAM01", 1.7, NA_character_, "LAST", 0, 1.7,
"TEST01", "PAT01", "PARAM01", 3.01, NA_character_, "LAST", 0, 3.01,
)

expected_output <- tibble::tribble(
~STUDYID, ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASETYPE, ~BASE, ~CHG, ~PCHG,
"TEST01", "PAT01", "PARAM01", 0, "Y", "LAST", 0, 0, NA_real_,
"TEST01", "PAT01", "PARAM01", 1.7, "", "LAST", 0, 1.7, NA_real_,
"TEST01", "PAT01", "PARAM01", 3.01, "", "LAST", 0, 3.01, NA_real_,
"TEST01", "PAT01", "PARAM01", 1.7, NA_character_, "LAST", 0, 1.7, NA_real_,
"TEST01", "PAT01", "PARAM01", 3.01, NA_character_, "LAST", 0, 3.01, NA_real_,
)

expect_equal(derive_var_pchg(input)$PCHG, expected_output$PCHG, tolerance = 1e-7)
Expand Down
Loading

0 comments on commit 9206460

Please sign in to comment.