我的数据如下所示:
> head(df)
ID Comment
1 1 I ate dinner.
2 2 We had a three-course meal.
3 3 Brad came to dinner with us.
4 4 He loves fish tacos.
5 5 In the end, we all felt like we ate too much. Code 5.16
6 6 We all agreed; it was a magnificent evening.72 points.
我想创建两个新列,一个称为A
,一个称为B
。如果出现以下任何单词/短语,我希望 A 列等于 1:如果出现以下任何单词/短语,我dinner,evening,we ate
希望 B 列等于 1:.in the end,all,Brad,5.16
我该怎么做呢?请注意,我需要完全匹配。