Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
错误:“filter()”输入“…1”有问题。x不能强制类型';关闭';到类型为'的向量;字符';_R - Fatal编程技术网

错误:“filter()”输入“…1”有问题。x不能强制类型';关闭';到类型为'的向量;字符';

错误:“filter()”输入“…1”有问题。x不能强制类型';关闭';到类型为'的向量;字符';,r,R,运行此代码时: ESS_subset <- ESS_subset %>% filter(!grepl('AL|XK|UA|RU', C)) 这是为什么?我该如何修复它 我已尝试查找它(有关于同一错误消息的问题)。但是,我无法将答案转移到我的案例中 谢谢你的帮助 编辑: 提取我需要清理的数据 > head(ESS_subset) cntry stfdem gndr agea hinctnta clsprty polintr eisced icpdwk2 1 AL

运行此代码时:

ESS_subset <- ESS_subset %>% filter(!grepl('AL|XK|UA|RU', C))
这是为什么?我该如何修复它

我已尝试查找它(有关于同一错误消息的问题)。但是,我无法将答案转移到我的案例中

谢谢你的帮助

编辑:

提取我需要清理的数据

> head(ESS_subset)
  cntry stfdem gndr agea hinctnta clsprty polintr eisced icpdwk2
1    AL      0    1   63        5       1       1      2       1
2    AL      5    2   29        2       1       3      4       2
3    AL      2    2   66        2       1       2      4       2
4    AL      2    1   NA       NA       1       4     NA       2
5    AL      7    1   59        2       1       2      1       2
6    AL      5    1   74        2       2       2      1       2

列名为“cntry”,因此我们需要

library(dplyr)
ESS_subset %>% 
       filter(!grepl('AL|XK|UA|RU', cntry))

或使用
stringr

library(stringr)
ESS_subset %>%
      filter(str_detect(cntry, 'AL|XK|UA|RU', negate = TRUE))

你有一个名为
C
的列吗?不,我没有。我的问题中包含了我需要清理的数据摘录。根据代码,不清楚您期望的是什么,因为
C
不存在。我实际上不记得C的用途。但是,
ESS_subset%过滤器(!grepl(!AL | XK | UA | RU'))
会导致相同的错误。是否需要
ESS_subset%>%过滤器(!grepl(!AL | XK | UA | RU',cntry))
library(stringr)
ESS_subset %>%
      filter(str_detect(cntry, 'AL|XK|UA|RU', negate = TRUE))