r - 在 quo() 中使用字符串并在 rlang 包中获取字符串本身内部的表达式
问题描述
使用 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
推荐阅读
- visual-studio-2019 - 如何在 Visual Studio 2019 上恢复正常的“新项目”窗口
- ios - 设置 UISlider 的最小值和最大值时出错
- asp.net-core - SelectPDF for .Net :DllNotFoundException: 无法加载 DLL 'libgdiplus': 找不到指定的模块
- azure-devops - Azure DevOps 与 Microsoft AppCenter
- react-native - 如何在单击气泡触摸时删除消息?React Native Gifted 聊天库
- angular - 调用 web 服务时出现问题,可能与 CORS 有关
- python - python中数据框的简单日志:错误:'type'对象不支持项目分配
- operators - 有没有办法对值进行分组,然后使用 RxJava 计算总和
- python - 与 Python Selenium 一起使用的 chromedriver 是否存储 cookie
- javascript - 当 URL 启动时,需要在静态 HTML 页面上启用一个按钮