Skip to contents

Derive percent change from baseline (PCHG) in a BDS dataset

Usage

derive_var_pchg(dataset)

Arguments

dataset

Input dataset AVAL and BASE are expected.

Value

The input dataset with an additional column named PCHG

Details

Percent change from baseline is calculated by dividing change from baseline by the absolute value of the baseline value and multiplying the result by 100.

Examples

library(tibble)

advs <- tribble(
  ~USUBJID, ~PARAMCD, ~AVAL, ~ABLFL, ~BASE,
  "P01",    "WEIGHT", 80,    "Y",    80,
  "P01",    "WEIGHT", 80.8,  "",     80,
  "P01",    "WEIGHT", 81.4,  "",     80,
  "P02",    "WEIGHT", 75.3,  "Y",    75.3,
  "P02",    "WEIGHT", 76,    "",     75.3
)
derive_var_pchg(advs)
#> # A tibble: 5 × 6
#>   USUBJID PARAMCD  AVAL ABLFL  BASE  PCHG
#>   <chr>   <chr>   <dbl> <chr> <dbl> <dbl>
#> 1 P01     WEIGHT   80   "Y"    80   0    
#> 2 P01     WEIGHT   80.8 ""     80   1.00 
#> 3 P01     WEIGHT   81.4 ""     80   1.75 
#> 4 P02     WEIGHT   75.3 "Y"    75.3 0    
#> 5 P02     WEIGHT   76   ""     75.3 0.930