8  Flags

Flags are named groups of columns which can be used to slice or filter the yspec object.

8.1 Specification

Flags get listed in the SETUP__ block, usually at the top of the yaml file. Under the flags header, we have two named groups of columns

  • covariate: including WT and ALB
  • tran: including AMT and CMT
# inline/test.yml
 
SETUP__:
  flags: 
    covariate: [WT, ALB]
    tran: [AMT, CMT]
C:
  short: comment
WT: 
  short: weight
ALB: 
  short: albumin
AMT: 
  short: dose amount
CMT: 
  short: compartment number

8.2 Checking flags

On reading in this yaml file

spec <- ys_load("inline/test.yml")
spec
 name info unit short              source
 C    ---  .    comment            .     
 WT   ---  .    weight             .     
 ALB  ---  .    albumin            .     
 AMT  ---  .    dose amount        .     
 CMT  ---  .    compartment number .     

we can see the available flags in the yspec object meta data

get_meta(spec)$flags
$covariate
[1] "WT"  "ALB"

$tran
[1] "AMT" "CMT"

The flags object is a named list of character vectors.

When a column is identified under a flag, there is a logical indicator set in the dots field for that column. For example

spec$AMT$dots
$covariate
[1] FALSE

$tran
[1] TRUE

Notice that tran is TRUE while covariate is FALSE. Because we set flags, every column in the yspec object will have data, either TRUE or FALSE on these flags. Checking C

spec$C$dots
$covariate
[1] FALSE

$tran
[1] FALSE

8.3 Filtering on a flag

This means that I can ask for the columns under the tran flag with

ys_filter(spec, tran)
 name info unit short              source
 AMT  ---  .    dose amount        .     
 CMT  ---  .    compartment number .     

and I can ask for the covariate columns with

ys_filter(spec, covariate) %>% axis_col_labs()
            WT            ALB 
  "WT//weight" "ALB//albumin"