Closed famax2 closed 3 years ago
Hi @famax2, this doesn't look like an issue with the lesson material to me. A good place to ask questions like this is https://community.rstudio.com/ or https://stackoverflow.com/
For more info on where and how to ask for help, see https://datacarpentry.org/R-ecology-lesson/00-before-we-start.html#Asking_for_help
Anyways, you can probably achieve what you are trying to do with a combination of mutate(), str_detect(), and as_numeric()
Hi, I'm working on survey data and I want to create a new variable from an existing variable data. The existing variable 'medication' has names of the medicines the participants used as text. I want to create a new variable 'Iron' that flags 1 if the medication variable has "iron" in it. I also want to create another variable 'folate' that flags 1 if the medication variable has folate in it.
The medication variable has different names of the same drug written either as e.g., iron, or many drugs e.g., iron, paracetamol, ironsupp etc.