在dplyr中反转quo()(Inverse of quo() in dplyr)

编程入门 行业动态 更新时间:2024-10-22 20:24:23
dplyr中反转quo()(Inverse of quo() in dplyr)

使用dplyr 0.7.4的新quosure语法,我相信我应该能够做类似!!quo(1) (期待1 )的事情,但它会返回错误

library(dplyr) !!quo(1) Error in !quo(1) : invalid argument type

为什么这不起作用? (注意,在基数R中,可以执行eval(quote(1)) 。什么是dplyr模拟?)

......是!! 仅在dpl​​yr函数中定义?

Using the new quosure syntax for dplyr 0.7.4, I believe I should be able to do something like !!quo(1) (expecting 1), yet it returns the error

library(dplyr) !!quo(1) Error in !quo(1) : invalid argument type

Why doesn't this work? (Note that in base R, one can do eval(quote(1)). What is the dplyr analogue?)

... is !! only defined within dplyr functions?

最满意答案

!! 只在知道tidyeval框架的函数中定义,是的。 在普通的R代码中,它意味着连续两次! 的(逻辑 - 不)。

eval的等价物是rlang::eval_tidy :

eval_tidy(quo(42)) # [1] 42

!! is only defined within functions that are aware of the tidyeval framework, yes. In normal R code, it means two successive !'s (logical-not).

The equivalent of eval would be rlang::eval_tidy:

eval_tidy(quo(42)) # [1] 42

更多推荐

本文发布于:2023-08-06 17:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1454101.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:dplyr   quo   Inverse

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!