I have a column in a dataframe that looks like this:
STATUTE
961.41(1)(A)
961.41(1)(B)
961.41(1)(A)
961.41(1)(A)
961.41(1)(C)
I'm trying to use GREP to identify any record in "STATUTE" column that contains the string '961.41(1)(A)' and make a description in a new column if that string is found:
my_data$STATUTE_DESCR[grepl('961.41(1)(A)',my_data$STATUTE, ignore.case = TRUE)] <- "DELIVER/MANUF CONTROLLED SUBSTANCES"
Desired output:
STATUTE STATUTE_DESCR
961.41(1)(A) DELIVER/MANUF CONTROLLED SUBSTANCES
961.41(1)(B)
961.41(1)(A) DELIVER/MANUF CONTROLLED SUBSTANCES
961.41(1)(A) DELIVER/MANUF CONTROLLED SUBSTANCES
961.41(1)(A)4 DELIVER/MANUF CONTROLLED SUBSTANCES
961.41(1)(A)(B) DELIVER/MANUF CONTROLLED SUBSTANCES
961.41(1)(C)
But, the grep statement is not working with the parenthesis. Can anyone advise?