【发布时间】:2021-06-16 03:30:48
【问题描述】:
你能帮帮我吗?
我已经尝试了很多组合,但没有任何效果。
这里是例子:
library(dplyr)
foo <- function(AA,x){
mn <- make.names(x)
mn <- enquo(mn)
filter(AA,mn==min(!!mn))
}
aa <- data.frame(A=c("a","b","c","d"), B.D = c(1,2,1,3))
foo(aa,"B D")
输出是
Error: Base operators are not defined for quosures.
Do you need to unquote the quosure?
# Bad:
myquosure == rhs
# Good:
!!myquosure == rhs
Run `rlang::last_error()` to see where the error occurred.
而不是
filter(aa,B.D==min(B.D))
A B.D
1 a 1
2 c 1
能否请您帮助我使用我的函数获得所需的输出。
谢谢。
约翰
【问题讨论】:
-
欢迎来到 StackOverflow!如果您还没有这样做,请花一些时间查看要做什么when someone answers your question。访问help center,可以找到有关 StackOverflow 新用户的更多信息。