data(example_data)
require(dplyr)
require(magrittr)
encode_ordinals(example_data, ord_levels = c("N0","N1","N2"), n_stage)
# Note: "unequivocal" is present in t_stage but not in `ord_levels`.
# with `strict_levels` TRUE, t_stage is unmodified and a warning message is given:
encode_ordinals(example_data,
ord_levels = c("T1","T2","T3a", "T3b", "T4"), strict_levels = TRUE, t_stage) %>%
select(t_stage)
# with `strict_levels` FALSE, it is replaced with NA:
encode_ordinals(example_data,
ord_levels = c("T1","T2","T3a", "T3b", "T4"), strict_levels = FALSE, t_stage) %>%
select(t_stage)
Run the code above in your browser using DataLab