我有这个数据框
DF
ID WORD_LIST
1 APPLE
2 RED
3 SNOW
4 ANKARA
5 RENEW
我只想选择以“A”或“R”开头的单词
DF
ID WORD_LIST WORDS_A_R
1 APPLE APPLE
2 RED RED
3 SNOW NA
4 ANKARA ANKARA
5 RENEW RENEW
我试过这段代码
DF %>% mutate(WORDS_A_R = ifelse(grepl("^A" | "^R", WORD_LIST), as.character(WORD_LIST), NA))
但是出现这个错误
operations are possible only for numeric, logical or complex types