I have a list of characters and I would like to search for them and a create a column for them in R.
antifungals <- c("caspofungin", "fluconazole")
Here is an example:
Original dataframe:
patient | drug name |
---|---|
1 | caspofungin |
2 | fluconazole |
2 | fluconazole |
3 | amoxicillin |
Desired dataframe:
patient | drug name | category |
---|---|---|
1 | caspofungin | antifungal |
2 | fluconazole | antifungal |
2 | fluconazole | antifungal |
3 | amoxicillin |