Suppose, I have a table in the following format:
CowId Farm Week1
1 CB c("Staphylococcus aureus", "Escherichia coli")
2 CB No Growth
3 CB NA
4 CB Staphylococcus aureus
How can I check if Staphylococcus aureus is a member of the Week1 column? I tried
dt.wide %>%
filter(Week1 %in% "Staphylococcus aureus")
But it only captures CowId 4, not CowId 1. Any feedback would be helpful.
dt.wide <- structure(list(CowId = c(1L, 2L, 3L, 4L),
Farm = structure(c(1L, 1L, 1L, 1L),
.Label = c("CB", "CB", "CB", "CB"),
class = "factor"),
Week1 = list(c("Staphylococcus aureus", "Escherichia coli"), "No Growth", NA, "Staphylococcus aureus")),
row.names = c(NA, -4L),
class = c("tbl_df", "tbl", "data.frame"))