For your first point I can't know why are you getting that error without a reproducible example (it works for me on a clean environment with the sample data provided).
For the second point, it's giving incorrect results because I forgot to make it case insensitive, this would fix that.
df <- data.frame(stringsAsFactors=FALSE,
Unique.respondent.number = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
comment = c("I have seen many various charges in my life,
but I don’t like your saving rates",
"I like R Studio", "No comment",
"Main benefit is having low charges", NA, "Charge could be an issue",
"Issues with saving rates", "Good saving rates",
"Many benefits like reasonable charges", "NA"))
library(dplyr)
library(stringr)
df %>%
mutate(Charges_Fees = if_else(str_detect(comment, regex("charges?", ignore_case = TRUE)) &
!str_detect(comment, regex("benefits?", ignore_case = TRUE)), 1, 0),
Poor_Rates = if_else(str_detect(comment, regex("don.?t\\slike|issue", ignore_case = TRUE)) &
str_detect(comment, regex("saving\\srates", ignore_case = TRUE)), 1, 0)) %>%
select(-comment) %>%
mutate_all(~if_else(is.na(.), 0, .))
#> Unique.respondent.number Charges_Fees Poor_Rates
#> 1 1 1 1
#> 2 2 0 0
#> 3 3 0 0
#> 4 4 0 0
#> 5 5 0 0
#> 6 6 1 0
#> 7 7 0 1
#> 8 8 0 0
#> 9 9 0 0
#> 10 10 0 0
About the "only integers 0 or 1 are allowed" part, "NA" is not a character string, is the way R deals with missing values, it stands for "Not Available", but you can replace that with 0 if you want (as shown in the example above).
Yes, you can create the regular expression separately and reference it later
negative_sentiments <- regex("don.?t\\slike|issue|other words", ignore_case = TRUE)
You just have to find the right logical statement, to give you a hint, once you have created a variable with mutate you can refence its value, so you could check if any of the previos variables have value 1