Dan Davison | 30 Dec 20:35
Favicon

org tables and R

Hi all,

I've had a go at taking the org tables and R thing a bit further. I'm
using two different #+ lines in the org buffer: Lines starting with
#+TBLR: are in the standard org style (option:value) and can be used
to specify certain transformations of the table and standard plots of
the table data. In lines starting #+TBLR:: you can supply literal R
code, giving you full control over what you do with the table. M-x
org-table-R-apply makes happen whatever has been specified in those
lines. As long as the transformation results in something reasonably
one- or two-dimensional, then this is output to the org-buffer as an
org table (you can choose whether or not it replaces the original
table). You need to have R running in an inferior-ess-mode
buffer. Then, if you have this table,

| rowname | col1 | col2 |
|---------+------+------|
| row 1   |    1 |    2 |
| row 2   |    3 |    4 |
| total   |      |      |
#+TBLR:: x[3,] <- x[1,] + x[2,]
#+TBLR: rownames:1

org-table-R-apply turns it into 

| rownames(x) | col1 | col2 |
|-------------+------+------|
| row 1       |    1 |    2 |
| row 2       |    3 |    4 |
| total       |    4 |    6 |
(Continue reading)

Tom Short | 2 Jan 23:34
Favicon

Re: org tables and R

Dan Davison <davison <at> stats.ox.ac.uk> writes:

> There are more details below. The code is at
> 
> http://www.stats.ox.ac.uk/~davison/software/org-table-R/org-table-R.el

This is a neat way to interface to R and to make tables more useful to
me. I'm a big user of ESS/R and org-mode, and I've been looking at
ways to use them together more. 

If you want to input an org-mode table into R, here's one way to do it
with Dan's TBLR:

| col1 | col2 |
|------+------|
|    1 |    2 |
|    3 |    4 |
#+TBLR: replace:t
#+TBLR:: my.table <<- x

This assigns the table to the global variable "my.table" in R, and
because we have "replace:t", it doesn't append the table with a copy
of itself. That's a little kludgy, maybe an action to give the table a
name could do that a bit more readily.

If you want to reverse that and take an R table and put it into an
org-mode table, you can do this:

| |
#+TBLR:: x <- r.table
(Continue reading)

Carsten Dominik | 22 Jan 09:09
Favicon

Re: org tables and R


Hi everyone,

should we include Dan's code as a contributed package or
even merge it into org-plot?

- Carsten

On Dec 30, 2008, at 8:35 PM, Dan Davison wrote:

> Hi all,
>
> I've had a go at taking the org tables and R thing a bit further. I'm
> using two different #+ lines in the org buffer: Lines starting with
> #+TBLR: are in the standard org style (option:value) and can be used
> to specify certain transformations of the table and standard plots of
> the table data. In lines starting #+TBLR:: you can supply literal R
> code, giving you full control over what you do with the table. M-x
> org-table-R-apply makes happen whatever has been specified in those
> lines. As long as the transformation results in something reasonably
> one- or two-dimensional, then this is output to the org-buffer as an
> org table (you can choose whether or not it replaces the original
> table). You need to have R running in an inferior-ess-mode
> buffer. Then, if you have this table,
>
> | rowname | col1 | col2 |
> |---------+------+------|
> | row 1   |    1 |    2 |
> | row 2   |    3 |    4 |
> | total   |      |      |
(Continue reading)

Graham Smith | 22 Jan 14:19

Re: org tables and R

Carsten

> should we include Dan's code as a contributed package or
> even merge it into org-plot?

I would like to see it included some how, as, for me, the more
integration between org-mode and R the better.

As to how it should be included, I must leave to other who more about
Org-mode, Emacs, ESS and R than I do.

Graham

_______________________________________________
Emacs-orgmode mailing list
Remember: use `Reply All' to send replies to the list.
Emacs-orgmode <at> gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode


Gmane