0

I have a column reasons with rows of survey respondents. Responses in reasons are separated by comma, so one cell in the column reasons would read reason1, reason2, reason3. I want to count entries that include reason1 (whether its the only reason listed or not). So far, I have done this

hair1 = read_excel('hair1.xlsx')
reason1 = data.frame(subset(hair1, reasons=='reason1'))

This only returns survey respondents that listed reason1 and not those who may have listed reason1 with other reasons as well.

dput(head(hair1)) structure(list(reasons = c("reason1, reason2, reason3","reason1, reason2")

1 Answers1

1

Subset with one equal sign instead of two worked

reason1 = data.frame(subset(hair1, reasons="reason1"))