0

这是关于R的。有人可以看看这个:

{library(forcats)
x <- filter(gss_cat, rincome != regex("not applicable", ignore_case = TRUE))}

ignore_case = TRUE没有效果。“不适用”和“不适用”在搜索中看起来仍然不同。

4

1 回答 1

1

考虑这个例子:

df <- data.frame(a = c('This is not applicable', 'But this is applicable', 
                       'This is still NOT aPPLicable'))

您需要使用regex以下stringr功能之一str_detect

library(dplyr)
library(stringr)

df %>% filter(str_detect(a, regex('not applicable', 
              ignore_case = TRUE), negate = TRUE))

#                      a
#1 But this is applicable

或在基础 R 中subset使用grepl

subset(df, !grepl('not applicable', a, ignore.case = TRUE))
于 2020-06-30T05:28:22.743 回答