【问题标题】:Output results of cat() in emacs org R source blockcat() 在 emacs org R 源代码块中的输出结果
【发布时间】:2016-03-07 19:36:23
【问题描述】:

我正在尝试获取包含在我的 emacs org 文件中的 cat() 命令的结果。我正在尝试以下

#+BEGIN_SRC R :session *R* :exports results :results replace output raw :eval export
 cat(c("1","2","3"))
#+END_SRC

当我评估时,我什么也看不到。

当我这样做时:

#+BEGIN_SRC R :session *R* :exports results :results replace output raw :eval export
 print(c("1","2","3"))
#+END_SRC

并评估我得到这个:

#+RESULTS:
[1] "1" "2" "3"

我不能使用。

背景:我想在 R 中打印乳胶表的元素,然后将其包含在制表环境中的导出中。我知道存在像 xtable() 这样的函数,但这是最灵活的方法,非常适用于复杂的表。我已经在 Sweave 中使用 cat() 完成了该操作,并且效果很好。

谢谢!

【问题讨论】:

    标签: r emacs org-mode


    【解决方案1】:

    Eric Sc​​hulte 在类似的帖子中解决了这个问题:

    https://lists.gnu.org/archive/html/emacs-orgmode/2013-03/msg01600.html

    如果没有换行符,则不会注意到结果。但是,将换行参数放在打印参数中也很重要,否则结果将包含 R 中下一行的“>”。

    所以这行得通:

    #+BEGIN_SRC R :session *R* :results output raw
      cat(c("1","2","3","\n"))
    #+END_SRC
    
    #+RESULTS:
    1 2 3
    

    【讨论】:

      猜你喜欢
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多