Relevel serotype data into an factor based on PCV group status and serotype name.
Source:R/utils-serotype-scales.R
relevel_serotypes.Rd
Relevel serotype data into an factor based on PCV group status and serotype name.
Arguments
- serotypes
a vector of serotypes as a factor or character.
- ...
an unwrapped version of the
exprs
parameter- exprs
a list of formulae with a predicate on the LHS and a PCV group name on the RHS. which are interpreted as the parameters for a
dplyr::case_when
call. This must be protected against interpretation by wrapping it inrlang::exprs()
. The predicates are tested againstavoncap::serotype_data$map
and could use any of the following columns 'serotype', 'PCV7', 'PCV13', 'PCV15', 'PCV20', 'PPV23', 'PCV13on7', 'PCV15on13', 'PCV20on15', 'PPV23on20', 'PCV10SSI', 'PCV10GSK', 'PCV15Zhifei', 'PCV24Vaxcyte', 'PCV24Affinivax' a default option of the formTRUE ~ "Non PCV serotype"
must exist to capture unmatched items.
Examples
x = rlang::exprs(
PCV7 ~ "PCV7",
PCV15 ~ "PCV15-7",
TRUE ~ "Non-PCV15 serotype"
)
relevel_serotypes(avoncap::phe_serotypes, exprs=x)
#> [1] <NA>
#> 50 Levels: 4 6B 9V 14 18C 19F 23F 1 3 5 6A 7F 19A 22F 33F 2 6C 7C 8 9N ... 38
relevel_serotypes(avoncap::phe_serotypes)
#> [1] <NA>
#> 50 Levels: 4 6B 9V 14 18C 19F 23F 1 3 5 6A 7F 19A 22F 33F 8 10A 11A 12F ... 38
relevel_serotypes(avoncap::phe_serotypes,
PCV24Affinivax ~ "Affinivax",
TRUE ~ "Non-affinivax"
)
#> [1] <NA>
#> 50 Levels: 1 2 3 4 5 6A 6B 7F 8 9N 9V 10A 11A 12F 14 15B 17F 18C 19A 19F ... 38