【问题标题】:Setting whether an R session is `interactive`设置 R 会话是否为“交互式”
【发布时间】:2018-08-21 06:42:52
【问题描述】:

#rstats 中的interactive() 是否基于一些可设置的选项?

我正在将下载计时器(和其他杂物)打印到使用 snakemake/rpy2 管道构建的 Rmarkdown pdf 中。诚然,我可以使用 Rscript 而不是 rpy2 来运行我的 R 代码,但使用 rpy2 似乎更整洁。

理想情况下,我想使用 rpy2 链接到 R 会话,并仅指示 R 以非交互方式运行。但我不知道该怎么做

【问题讨论】:

    标签: r rpy2


    【解决方案1】:

    rpy2 允许用户随时切换交互标志(默认情况下,它会从交互标志开始)。这在 R 中是不可能的。R 以批处理模式、非交互或交互模式(例如,R 控制台)运行。

    不幸的是,该文档不完整,该功能仅在更改日志中提及: https://rpy2.github.io/doc/v2.9.x/html/changes.html#release-2-1-0

    (寻找set_interactive)。

    【讨论】:

    • 谢谢。但是,我实际上无法弄清楚如何使用它。 rpy2.rinterface 文档中似乎只提到了交互使用,set_interactive 出现在 rinterface/_rinterface.c 中。所以我尝试了from rpy2 import rinterface as ri;但rinterface 只导出set_[choosefile|cleanup|flushconsole|initoptions|readconsole|resetconsole|showfiles|showmessage|writeconsole_regular|writeconsole_warnerror]。
    • 可能不会导入到rpy2.rinterface。试试rpy2.rinterface._rinterface。
    猜你喜欢
    • 1970-01-01
    • 2012-10-18
    • 2020-10-27
    • 1970-01-01
    • 2011-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多