2009-02-05 23:04:09 +00:00
|
|
|
#+TITLE: rorg --- R and org-mode
|
|
|
|
|
|
|
|
Please feel free to change the layout of this file, I'm just putting
|
|
|
|
this here to get things started.
|
|
|
|
|
2009-02-05 23:47:20 +00:00
|
|
|
* Objectives
|
|
|
|
** Import data into R from org
|
2009-02-05 23:54:46 +00:00
|
|
|
Org-mode includes orgtbl-mode, an extremely convenient way of using
|
|
|
|
tabular data in a plain text file. Currently, spreadsheet
|
|
|
|
functionality is available in org tables using the emacs package
|
|
|
|
calc. It would be a boon both to org users and R users to allow
|
|
|
|
org tables to be manipulated with the R programming language. Org
|
|
|
|
tables give R users an easy way to enter and display data; R gives
|
|
|
|
org users a powerful way to perform vector operations, statistical
|
|
|
|
tests, and visualization on their tables.
|
|
|
|
|
|
|
|
*** Implementations
|
|
|
|
**** naive
|
|
|
|
Naive implementation would be to use =(org-export-table "tmp.csv")=
|
2009-02-06 00:37:17 +00:00
|
|
|
and =(ess-exec "read.csv('tmp.csv')")=.
|
2009-02-05 23:47:20 +00:00
|
|
|
**** org-R
|
|
|
|
[[file:existing_tools/org-R.el::defun%20org%20R%20export%20to%20csv%20csv%20file%20options][org-R-export-to-csv]]
|
|
|
|
**** org-exp-blocks
|
|
|
|
**** RweaveOrg
|
|
|
|
NA
|
|
|
|
|
2009-02-06 01:07:09 +00:00
|
|
|
** evaluate R code and make the output available for processing in an org buffer
|
|
|
|
** evaluate R code and format the output for export
|
|
|
|
|
|
|
|
* Notes
|
|
|
|
** Special editing and evaluation of source code in R blocks
|
|
|
|
Unfortunately org-mode how two different block types, both useful.
|
|
|
|
In developing RweaveOrg, a third was introduced.
|
|
|
|
|
|
|
|
Eric is leaning towards using the =#+begin_src= blocks, as that is
|
|
|
|
really what these blocks contain is source code. Austin believes
|
|
|
|
that specifying export options at the beginning of a block is
|
|
|
|
useful functionality, to be preserved if possible.
|
|
|
|
|
|
|
|
Note that upper and lower case are not relevant in block headings.
|
|
|
|
|
|
|
|
*** Source code blocks
|
|
|
|
Org has an extremely useful method of editing source code and
|
|
|
|
examples in their native modes. In the case of R code, we want to
|
|
|
|
be able to use the full functionality of ESS mode, including
|
|
|
|
interactive evaluation of code.
|
|
|
|
|
|
|
|
Source code blocks look like the following and allow for the
|
|
|
|
special editing of code inside of the block through
|
|
|
|
`org-edit-special'.
|
2009-02-06 00:37:17 +00:00
|
|
|
|
|
|
|
#+BEGIN_SRC r
|
|
|
|
|
|
|
|
,## hit C-c ' within this block to enter a temporary buffer in r-mode.
|
|
|
|
|
|
|
|
,## while in the temporary buffer, hit C-c C-c on this comment to
|
|
|
|
,## evaluate this block
|
|
|
|
a <- 3
|
|
|
|
a
|
|
|
|
|
|
|
|
,## hit C-c ' to exit the temporary buffer
|
|
|
|
#+END_SRC
|
2009-02-06 00:00:05 +00:00
|
|
|
|
2009-02-06 00:59:19 +00:00
|
|
|
*** dblocks
|
2009-02-06 01:07:09 +00:00
|
|
|
dblocks are useful because org-mode will automatically call
|
2009-02-06 00:59:19 +00:00
|
|
|
`org-dblock-write:dblock-type' where dblock-type is the string
|
|
|
|
following the =#+BEGIN:= portion of the line.
|
2009-02-05 23:04:09 +00:00
|
|
|
|
2009-02-06 01:07:09 +00:00
|
|
|
dblocks look like the following and allow for evaluation of the
|
|
|
|
code inside of the block by calling =\C-c\C-c= on the header of
|
|
|
|
the block.
|
|
|
|
|
2009-02-06 00:00:05 +00:00
|
|
|
#+BEGIN: dblock-type
|
|
|
|
#+END:
|
2009-02-05 23:04:09 +00:00
|
|
|
|
2009-02-06 01:07:09 +00:00
|
|
|
*** R blocks
|
|
|
|
In developing RweaveOrg, Austin created [[file:existing_tools/RweaveOrg/org-sweave.el][org-sweave.el]]. This
|
|
|
|
allows for the kind of blocks shown in [[file:existing_tools/RweaveOrg/testing.Rorg][testing.Rorg]]. These blocks
|
|
|
|
have the advantage of accepting options to the Sweave preprocessor
|
|
|
|
following the #+BEGIN_R declaration.
|
|
|
|
|
|
|
|
|
2009-02-06 00:00:05 +00:00
|
|
|
* tasks
|
2009-02-05 23:04:09 +00:00
|
|
|
|
2009-02-06 00:00:05 +00:00
|
|
|
* buffer dictionary
|
|
|
|
LocalWords: DBlocks dblocks
|