在 quo() 中使用字符串并在 rlang 包中获取字符串本身内部的表达式

Using strings inside quo() and get the expression inside the string itself, in rlang package

使用 rlang,我想在输入 quo("just_an_example") 时获得 quo(just_an_example) 的结果。 也就是说我要获得

<quosure: global>
~just_an_example

但是当 quo() 中的表达式是字符串 "just_an_example" 时。任何帮助将不胜感激。

但是我不确定解决方案,因为我无法完全理解这个问题,但即使您在 rlang::quo 函数中输入带引号的字符串,您似乎也希望得到相同的结果。我正在使用 rlang_0.2.0.9001 版本。

你可以试试这个:

 library(rlang)

quo(!!as.symbol("just_an_example"))

quo(!!sym("just_an_example"))

输出:

> quo(!!sym("just_an_example"))
<quosure>
  expr: ^just_an_example
  env:  global