Skip to contents

Derive Reference Range Indicator

Usage

derive_var_anrind(dataset)

Arguments

dataset

The input dataset

Value

The input dataset with additional column ANRIND

Details

ANRIND is set to

  • "NORMAL" if AVAL is greater or equal ANRLO and less than or equal ANRHI; or if AVAL is greater than or equal ANRLO and ANRHI is missing; or if AVAL is less than or equal ANRHI and ANRLO is missing

  • "LOW" if AVAL is less than ANRLO and either A1LO is missing or AVAL is greater than or equal A1LO

  • "HIGH" if AVAL is greater than ANRHI and either A1HI is missing or AVAL is less than or equal A1HI

  • "LOW LOW" if AVAL is less than A1LO

  • "HIGH HIGH" if AVAL is greater than A1HI

See also

Examples

library(tibble)
library(dplyr, warn.conflicts = FALSE)
library(admiral.test)
data(admiral_vs)

ref_ranges <- tribble(
  ~PARAMCD, ~ANRLO, ~ANRHI, ~A1LO, ~A1HI,
  "DIABP",      60,     80,    40,    90,
  "PULSE",      60,    100,    40,   110
)

admiral_vs %>%
  mutate(
    PARAMCD = VSTESTCD,
    AVAL = VSSTRESN
  ) %>%
  filter(PARAMCD %in% c("PULSE", "DIABP")) %>%
  derive_vars_merged(ref_ranges, by_vars = exprs(PARAMCD)) %>%
  derive_var_anrind() %>%
  select(USUBJID, PARAMCD, AVAL, ANRLO:ANRIND)
#> # A tibble: 16,411 x 8
#>    USUBJID     PARAMCD  AVAL ANRLO ANRHI  A1LO  A1HI ANRIND
#>    <chr>       <chr>   <dbl> <dbl> <dbl> <dbl> <dbl> <chr> 
#>  1 01-701-1015 DIABP      64    60    80    40    90 NORMAL
#>  2 01-701-1015 DIABP      83    60    80    40    90 HIGH  
#>  3 01-701-1015 DIABP      57    60    80    40    90 LOW   
#>  4 01-701-1015 DIABP      68    60    80    40    90 NORMAL
#>  5 01-701-1015 DIABP      59    60    80    40    90 LOW   
#>  6 01-701-1015 DIABP      71    60    80    40    90 NORMAL
#>  7 01-701-1015 DIABP      56    60    80    40    90 LOW   
#>  8 01-701-1015 DIABP      51    60    80    40    90 LOW   
#>  9 01-701-1015 DIABP      61    60    80    40    90 NORMAL
#> 10 01-701-1015 DIABP      67    60    80    40    90 NORMAL
#> # … with 16,401 more rows