Could you please help me.
I tried already many combinations, but nothing works.
Here the example:
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")
The output is
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.
instead of
filter(aa,B.D==min(B.D))
A B.D
1 a 1
2 c 1
Could you please help me to get the desired output using my function.
Thank you.
John