R 组织模式:以编程方式向表中添加标题

R 组织模式:以编程方式向表中添加标题,r,emacs,org-mode,org-table,R,Emacs,Org Mode,Org Table,我在组织模式下定义了一个表: `#+RESULTS[4fc5d440d2954e8355d32d8004cab567f9918a64]: table | 7.4159 | 3.0522 | 5.9452 | | -1.0548 | 12.574 | -6.5001 | | 7.4159 | 3.0522 | 5.9452 | | 5.1884 | 4.9813 | 4.9813 | ` 我想制作下表: #+标题:我的表格的标题 ||第一组|第二组|第三组| |--------+--

我在组织模式下定义了一个表:

`#+RESULTS[4fc5d440d2954e8355d32d8004cab567f9918a64]: table
|  7.4159 | 3.0522 |  5.9452 |
| -1.0548 | 12.574 | -6.5001 |
|  7.4159 | 3.0522 |  5.9452 |
|  5.1884 | 4.9813 |  4.9813 |
`
我想制作下表:

#+标题:我的表格的标题
||第一组|第二组|第三组|
|--------+---------+---------+---------|
|计划1 | 7.416 | 3.052 | 5.945|
|平面图2 |-1.055 | 12.574 |-6.5|
|计划3 | 7.416 | 3.052 | 5.945|
|计划4 | 5.1884 | 4.9813 | 4.9813 |

我怎样才能做到这一点?以下是我(在R中)尝试的内容:

但这当然行不通,我得到的是:

`#RESULTS:
| X7.4159 | X3.0522 | X5.9452 |
|---------+---------+---------|
| -1.0548 |  12.574 | -6.5001 |
|  7.4159 |  3.0522 |  5.9452 |
|  5.1884 |  4.9813 |  4.9813 |`
有什么建议吗


谢谢

这一点非常接近。首先定义此函数:

#+BEGIN_SRC emacs-lisp
(defun add-caption (caption)
  (concat (format "org\n#+caption: %s" caption)))
#+END_SRC
接下来,使用这种src块。我使用python,但它也应该在R中工作,您只需要:wrap。我通过var传递了数据,如果在块中生成数据,则不需要它

#+BEGIN_SRC python :results value :var data=data :wrap (add-caption "Some really long, uninteresting, caption about data that is in this table.")
data.insert(0, ["", "group 1", "group 2", "group 3"])
data.insert(1, None)
return data
#+END_SRC
这个输出

#+BEGIN_org
#+caption: Some really long, uninteresting, caption about data that is in this    table.
|        | group 1 | group 2 | group 3 |
|--------+---------+---------+---------|
| plan 1 |   7.416 |   3.052 |   5.945 |
| plan 2 |  -1.055 |  12.574 |    -6.5 |
| plan 3 |   7.416 |   3.052 |   5.945 |
| plan 4 |  5.1884 |  4.9813 |  4.9813 |
#+END_org

我想它也可以出口。

谢谢,这正是我想要的!
#+BEGIN_org
#+caption: Some really long, uninteresting, caption about data that is in this    table.
|        | group 1 | group 2 | group 3 |
|--------+---------+---------+---------|
| plan 1 |   7.416 |   3.052 |   5.945 |
| plan 2 |  -1.055 |  12.574 |    -6.5 |
| plan 3 |   7.416 |   3.052 |   5.945 |
| plan 4 |  5.1884 |  4.9813 |  4.9813 |
#+END_org