I'm using a dataset that included diagnoses coding, and I'm trying to see whether follow_up_code is in discharge_codes. Sadly, the discharge codes have been provided as a string, rather than a vector.
mre <- tribble(
~patient_id, ~discharge_codes, ~follow_up_code,
1234 , "A_B_C" , "A",
4567 , "D_E_F" , "C",
7890. , "A_C_E". , "E"
)
I've tried using flatten_chr() with str_split() to allow me to search follow_up_code %in% discharge_codes, but this flattens discharge_codes entirely (rather than by patient), and using rowwise() %>% mutate(... flatten_chr()) errors as ".x must be a list, not a character vector".
I feel I must be missing something, either in the approach I'm taking, or there being a much more straightforward way to achieve this?