Hi,
I'm replacing values in the column "Specimen Source" and have the code below.
I still need to replace a huge list of the remaining values. Is there a way to do that without listing as in the code below? Maybe using something like an "else' step for example! Processing: SpecSrc.JPG...
LAB<-LAB %>% #order matters, so go from the most specific to the most general
mutate(specimen_formatted= (case_when(
is.na(Specimen_Source) ~ "Missing",
grepl("Blood|Bld|Blood Specimen|Blood venous|Line Blood|Venous blood|", SpecimenSource, ignore.case = TRUE)~"Blood",
grepl("Blood|BLOOD CULTURE #1|BLOOD CULTURE (2ND SET)|BLOOD CULTURE (1ST SET)|BLOOD CULTURE|BLOOD CULTURE #2|CULTURE, BLOOD #1|CULTURE, BLOOD #2|FUNGAL BLOOD CULTURE|BACT CULT BLOOD|CULT BLOOD|CULTURE BLOOD|CULTURE, BLOOD", LocalTestDescription, ignore.case = TRUE)~"Blood")))