org-babel如何摆脱作为外壳程序输入的R代码的输出中的[1]

问题描述 投票:1回答:1

[[#]标记作为每个元素的索引的标签包含在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个回答
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也可以。

© www.soinside.com 2019 - 2024. All rights reserved.