Sorry if it's a dumb question, but I'm not sure what keywords to use to find the answer so nothing I get is quite what I'm looking for.
I have a column: df$infecting_agent. The entries there are things like "staphylococcus" "bacteria" "virus" "bacterial", etc.
I want two new columns: df$bacteria and df$virus
I want all observations to have a "1" for bacteria if the diagnoses entry contains "bact" or "cocc" or "staph" where anything is allowed before or after what's in quotes. I'll do similar for the virus column, many observations will have a 1 in both columns.
Can someone tell me what package to use or at least what the "lingo" is I should be using to search for my problem? I tried variations of "replace string with 0 or 1 in R" but I don't think I'm getting anything relevant.
Thank you all!