【问题标题】:Using strings inside quo() and get the expression inside the string itself, in rlang package在 quo() 中使用字符串并在 rlang 包中获取字符串本身内部的表达式
【发布时间】:2018-10-10 17:56:00
【问题描述】:

使用 rlang,我想获得 quo(just_an_example) 的结果,同时键入 quo("just_an_example")。 这意味着我想获得

<quosure: global>
~just_an_example

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

【问题讨论】:

    标签: r string tidyverse evaluation


    【解决方案1】:

    但是我不确定解决方案,因为我无法完全理解这个问题,但即使您在 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-02-14
      • 2018-05-07
      • 1970-01-01
      • 2019-05-02
      • 1970-01-01
      • 2017-06-07
      • 1970-01-01
      相关资源
      最近更新 更多