[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] [babel][PATCHES] ob-R patches for review

From: Charles C. Berry
Subject: Re: [O] [babel][PATCHES] ob-R patches for review
Date: Mon, 12 May 2014 15:05:11 -0700
User-agent: Alpine 2.00 (OSX 1167 2008-08-23)

On Mon, 12 May 2014, Rainer M Krug wrote:

Eric Schulte <address@hidden> writes:

If not would you mind submitting a version of the patches split into
multiple commits with as much of the hard-coded R code as feasible
placed into customizable variables along the lines of the
`org-babel-R-assign-elisp-function' variable suggested by Charles.

I am thinking of actually not providing the R code in org-variables, but
to put them into R files and to source them. By doing this, the
customization could be done in R, which will be much easier for R users
then to customize emacs variables.

I think this is a bad idea, such external R source files may be hard to
manage and load reliably across systems

I see your points, but I am looking at ESS (which is loading .R files as
well into the ESSR environment) and whose loading mechanism I want
to piggy back the loading of .R for org. If I understand the variable
transfer from org to R correctly, it anyway only works on local R
sessions, which makes it even easier to do then ESS which also caters
for remote R sessions.
My idea is to have all R code in one directory and to let ESS load it
upon initialization of ESS (which is a dependency of running R from org
anyway, if I am not mistaken).

Not quite. You can run R src blocks without (require 'ess) if they require no session. (I do not claim that anyone actually runs R src blocks who lacks a working ESS installation, just saying...)

I have a prototype working, and will keep
you posted. The complication would be that a newer version of ESS would
be needed.

Maybe load the ESS and R files if

  (and (fboundp 'ess-version)
       (not (string<
             "ess-version: <least-version>")))

and fallback to the existing version of ob-R.el (or something like it) otherwise.

The other option would be to just copy the code ESS uses into org, which
would make the process independent of changes in ESS. But I don't like
the duplication of code.

and it is not clear where they should live in the Org-mode repository.

I would suggest in a etc/R.

IIUC, someone on ESS core will support your effort. So maybe you can have an etc/ESSR/R/org-mode.R file.

Since you will have a mix of elisp and R, it might make sense to have minimal callouts on the org-mode side to an elisp wrapper on the ESS side. Then you can maintain the trickier elisp on the ESS side, so changes in elisp that require changes in R or vice versa can be made in unison.

Additionally, if the variables simply hold R code text, then users can
easily initialize them from R files locally with something like the

    (setq org-babel-R-assign-elisp-function
            (insert-file-contents-literally "personal.R")

I think this approach is much simpler.

True - but I like the simplicity of being able to customize the
behavior of org-babel-R by writing an R function without having to thin
about elisp. But maybe there is a way of doing both...

noweb will do it. Quote the chunk like this:

#+BEGIN_SRC emacs-lisp :noweb yes :tangle elisp-R.el
  (setq rlines "



Charles C. Berry                            Dept of Family/Preventive Medicine
cberry at ucsd edu                          UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, CA 92093-0901

reply via email to

[Prev in Thread] Current Thread [Next in Thread]