I have a data-frame with string variable column "disease". I want to filter the rows with partial match "trauma" or "Trauma". I am currently done the following using dplyr
and stringr
:
trauma_set <- df %>% filter(str_detect(disease, "trauma|Trauma"))
But the result shows includes "Nontraumatic" and "nontraumatic". How can I filter only "trauma, Trauma, traumatic or Traumatic" without including nontrauma or Nontrauma? Also, is there a I can define the string to detect without having to specify both uppercase and lowercase version of the string (as in both trauma and Trauma)?