[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [O] BUG: emacs orgmode ob-R.el function org-babel-R-evaluate-session
Re: [O] BUG: emacs orgmode ob-R.el function org-babel-R-evaluate-session over aggressively performs "; ; cleanup extra prompts left in output" and a possible workaround
Mon, 9 Nov 2015 20:04:38 +0000
> -----Original Message-----
> From: Charles C. Berry [mailto:address@hidden
> Sent: Saturday, November 07, 2015 6:33 PM
> To: Cook, Malcolm <address@hidden>
> Cc: address@hidden
> Subject: Re: BUG: emacs orgmode ob-R.el function org-babel-R-evaluate-
> session over aggressively performs "; ; cleanup extra prompts left in output"
> and a possible workaround
> On Sat, 7 Nov 2015, Cook, Malcolm wrote:
> > Thanks Chuck for setting this through.
> > I've wondered if there is not a better way for Babel to share an
> > interactive session with the user. For instance, if we wanted to
> > support a new form of results processing on addition to value and
> > output.... Namely, "transcript", wherein the results of evaluating a
> > source block would be a transcript of the season with statements
> > interwoven with their respective outputs.... I suspect that this would
> > not be easy extension of the current approach since it would require
> > parsing the source into statements that get evaluated sequentially with
> > visible results echoed into the transcript.
> You can do stuff like this using babel and some R code.
> Here is a start:
> --8<---------------cut here---------------start------------->8---
> #+NAME: my-block
> #+BEGIN_SRC R :eval no
> a <- 1
> #+BEGIN_SRC R :session :noweb yes :results value raw :wrap example
> > ls()
>  "a"
> > a <- 1
> > sqrt(a+2)
>  1.732051
> > ls()
>  "a"
> --8<---------------cut here---------------end--------------->8---
> I suppose you would want `:exports results'.
Sourcing a textConnection on a :noweb interpolated block will not handle
embedded quotes in the source block correctly. Adding an assignment of a
string to a variable in my-block reveals this (i.e. `b<-"asdf"`)
Nor does it extend to my underspecified conception of what :transcript output
would be. I intended that :transcript would generate a colorized source
blocks separated by results for statements which generated visible results.
You implementation makes the source and results undifferentiated. My mistake
for underspecifying my intention. I think I might be able to cobble what I
want using the 'evaluate' package
(https://cran.rstudio.com/web/packages/evaluate/evaluate.pdf) with an output
handler to format source as an R code block and results as R results block.
Probably not worth the effort. Or rather, probably already done within the