这是关于R的。有人可以看看这个:
{library(forcats)
x <- filter(gss_cat, rincome != regex("not applicable", ignore_case = TRUE))}
ignore_case = TRUE
没有效果。“不适用”和“不适用”在搜索中看起来仍然不同。
这是关于R的。有人可以看看这个:
{library(forcats)
x <- filter(gss_cat, rincome != regex("not applicable", ignore_case = TRUE))}
ignore_case = TRUE
没有效果。“不适用”和“不适用”在搜索中看起来仍然不同。
考虑这个例子:
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))