【问题标题】:org-babel how to get rid of [1] in the output of an R code that is the input of a shell oneorg-babel 如何在作为 shell 输入的 R 代码的输出中去掉 [1]
【发布时间】:2019-10-03 21:18:57
【问题描述】:

R 包含 [#] 标记作为每个元素索引的标签,但不幸的是,当此输出用作另一个块的输入时,这是一个问题。

我已经尝试使用cat 摆脱它,但这样我没有得到任何结果。有什么想法吗?

#+name: aux
#+begin_src R :results output
a <- c(-2, 2, 4, 5, 6, 7, -6, -4, 99, 101, -9, 2, 0, 1, 3, 123, 345, 678, 987, 543, 3567)
a
#+end_src

#+begin_src shell :results output :var ls=aux
for l in $ls; do
    echo "processing $l"
done;
#+end_src

#+RESULTS:
#+begin_example
processing [1]
processing -2
processing 2
processing 4
processing 5
processing 6
processing 7
processing -6
processing -4
processing 99
processing 101
processing -9
processing 2
processing 0
processing 1
processing 3
processing [16]
processing 123
processing 345
processing 678
processing 987
processing 543
processing 3567
#+end_example

【问题讨论】:

    标签: r emacs org-mode org-babel


    【解决方案1】:

    cat 应该可以工作,您只需打印到stdout

    #+begin_src R :results output
    a <- c(-2, 2, 4, 5, 6, 7, -6, -4, 99, 101, -9, 2, 0, 1, 3, 123, 345, 678, 987, 543, 3567)
    cat(a, file=stdout())
    #+end_src
    
    #+RESULTS: aux
    : -2 2 4 5 6 7 -6 -4 99 101 -9 2 0 1 3 123 345 678 987 543 3567
    

    或者,使用:results value verbatim 也可以。

    【讨论】:

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