使用与此类似的数据集:
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)
Run Code Online (Sandbox Code Playgroud)
如果我运行带有starts_with函数的东西:
df %>%
select(starts_with("all"))
Run Code Online (Sandbox Code Playgroud)
它工作正常并选择正确的列。但是,如果我尝试:
filter_at(df,
vars(starts_with("all")),
any_vars(. == "Y"))
Run Code Online (Sandbox Code Playgroud)
我收到错误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")
Run Code Online (Sandbox Code Playgroud)
我猜这是已安装软件包的问题,但不太确定如何修复它。软件包版本有:
dplyr_0.8.4
tidyselect_1.0.0
Run Code Online (Sandbox Code Playgroud)
有人有什么想法吗?