r - org-babel 如何在作为 shell 输入的 R 代码的输出中去掉 [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
解决方案
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
会起作用。
推荐阅读
- karate - 如何使用外部变量过滤地图列表
- python - 按周分组的 Python matplotlib 条形图
- c++ - 如何在析构函数期间同步
- iot - 我如何订阅 azure iot hub 设备到设备通信中的主题
- ruby-on-rails - Capybara 功能测试 ActionView::Template::Error
- android - Bintray 上的 Android 库缺少源和 javadoc
- kotlin - 是否可以期望来自 AxonFramework 中非轴突类的调度命令
- python - 如何从Python列表中仅获取特定项目
- javascript - ajax post应用的问题
- elasticsearch - 如何将用户定义的字段和值添加到弹性搜索查询