Hello all,
I have a simple question, but I can't find the correct code to do it. I tried grepl, but that didn't work. I want to create a value (string) for a new variable based on another variable containing a specific word.
If Var1 contains "apples" then var2="fruit"
Sample dataset
Var1 Var 2
apples Fruit
cats NA
green apples Fruit
Thanks!
Dan