[英]R starts_with error in filter_at (`starts_with()` must be used within a *selecting* function.)
使用类似于此的数据集:
id <- c("john","paul","george","ringo","mick","dozy","beaky","tich")
allow_a <- c("Y","N","Y","Y","","","Y","")
allow_b <- c("N","","N","","N","N","N","Y")
generic_a <- c("N","","","Y","Y","Y","N","")
generic_b <- c("N","","","N","Y","N","","Y")
df <- data.frame(id, allow_a, allow_b, generic_a, generic_b)
如果我用starts_with
函数运行一些东西:
df %>%
select(starts_with("all"))
它工作正常并选择正确的列。 但是,如果我尝试:
filter_at(df,
vars(starts_with("all")),
any_vars(. == "Y"))
我收到错误Error: `starts_with()` must be used within a *selecting* function.
如果我使用rlang::last_error()
来跟踪我得到的错误:
Backtrace:
1. dplyr::filter_at(...)
11. tidyselect::starts_with("all")
13. tidyselect::peek_vars(fn = "starts_with")
我想这是已安装软件包的问题,但不确定如何修复它。 软件包版本是:
dplyr_0.8.4
tidyselect_1.0.0
任何人的想法?
我不完全确定发生了什么,但经过今天的一些测试,它与expss
包有冲突。 我不知道为什么starts_with
这里挑出来,但contains
提到装载时expss
到库:
Loading required package: expss
Attaching package: ‘expss’
The following objects are masked from ‘package:tidyr’:
contains, nest
The following objects are masked from ‘package:data.table’:
copy, like
The following objects are masked from ‘package:dplyr’:
between, compute, contains, first, last, na_if, recode, vars
不确定如何追溯错误,但如果其他用户遇到相同的错误,这可能很有用...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.