emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Evaluating R source code line by line
@ 2014-12-13  2:26 Vikas Rawal
  2014-12-13 10:12 ` Daniele Pizzolli
  0 siblings, 1 reply; 7+ messages in thread
From: Vikas Rawal @ 2014-12-13  2:26 UTC (permalink / raw)
  To: org-mode mailing list

I have an R source code blocks called with the ":results value” option. I evaluate the code with C-c. When I do that, in my R session buffer, I get to see several + + + until the final value is obtained, and then the final value is shown, and inserted in my Org buffer.

I was wondering if there is an option somewhere that will allow me to instead see how each line in my R source code is evaluated. That is, the R session buffer should show each line being evaluated, and then show the final value as usual.

Vikas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Evaluating R source code line by line
  2014-12-13  2:26 Evaluating R source code line by line Vikas Rawal
@ 2014-12-13 10:12 ` Daniele Pizzolli
  2014-12-13 13:18   ` Vikas Rawal
  0 siblings, 1 reply; 7+ messages in thread
From: Daniele Pizzolli @ 2014-12-13 10:12 UTC (permalink / raw)
  To: org-mode mailing list


Hello,

Vikas Rawal writes:

> I have an R source code blocks called with the ":results value”
> option. I evaluate the code with C-c. When I do that, in my R session
> buffer, I get to see several + + + until the final value is obtained,
> and then the final value is shown, and inserted in my Org buffer.
>
> I was wondering if there is an option somewhere that will allow me to
> instead see how each line in my R source code is evaluated. That is,
> the R session buffer should show each line being evaluated, and then
> show the final value as usual.

Look at:
http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html

  Use ESS to step through evaluation line-by-line

    Use C-c ' to visit the edit buffer for your code block
    Use ess-eval-line-and-step to evaluate each line in turn
 
ess-eval-line-and-step is usually bound to C-c C-n

I guess that is possible to use the same R session by configuring the
session arguments and/or the ESS settings but I have not done it yet.

If you do not have ESS you can try a more lightweight solution with
isend-mode.

Best,
Daniele

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Evaluating R source code line by line
  2014-12-13 10:12 ` Daniele Pizzolli
@ 2014-12-13 13:18   ` Vikas Rawal
  2014-12-13 19:38     ` Aaron Ecay
  0 siblings, 1 reply; 7+ messages in thread
From: Vikas Rawal @ 2014-12-13 13:18 UTC (permalink / raw)
  To: Daniele Pizzolli, org-mode mailing list


On 13-Dec-2014, at 3:42 pm, Daniele Pizzolli <dan@toel.it> wrote:
> Look at:
> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html
> 
>  Use ESS to step through evaluation line-by-line
> 
>    Use C-c ' to visit the edit buffer for your code block
>    Use ess-eval-line-and-step to evaluate each line in turn
> 
> ess-eval-line-and-step is usually bound to C-c C-n

I know this and use it. But since my code evaluation is quite resource intensive, when I later evaluate the code using C-c C-c to insert results in my org buffer, it would be useful to see how far it is progressing.

Vikas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Evaluating R source code line by line
  2014-12-13 13:18   ` Vikas Rawal
@ 2014-12-13 19:38     ` Aaron Ecay
  2014-12-15 22:58       ` Vikas Rawal
  0 siblings, 1 reply; 7+ messages in thread
From: Aaron Ecay @ 2014-12-13 19:38 UTC (permalink / raw)
  To: Vikas Rawal, Daniele Pizzolli, org-mode mailing list

Hi Vikas,

2014ko abenudak 13an, Vikas Rawal-ek idatzi zuen:
> 
> On 13-Dec-2014, at 3:42 pm, Daniele Pizzolli <dan@toel.it> wrote:
>> Look at:
>> http://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html
>> 
>> Use ESS to step through evaluation line-by-line
>> 
>> Use C-c ' to visit the edit buffer for your code block
>> Use ess-eval-line-and-step to evaluate each line in turn
>> 
>> ess-eval-line-and-step is usually bound to C-c C-n
> 
> I know this and use it. But since my code evaluation is quite resource
> intensive, when I later evaluate the code using C-c C-c to insert
> results in my org buffer, it would be useful to see how far it is
> progressing.

See the thread beginning at
<http://mid.gmane.org/8638cfr7ua.fsf@somewhere.org>.  I’m not sure this
feature is actually workable, however, even aside from the performance
issues alluded to in that thread.  There are various methods that babel
uses to evaluate R code, not all of which are amenable to line-by-line
echoing.  In the future, I think babel should move towards an approach
which separates the code actually evaluated in R from the contents of
the code block further.  (See my patch at
<http://mid.gmane.org/87wqa9owhv.fsf@gmail.com> for an example of what I
mean).  This will make line-by-line echoing confusing (since what would
be echoed has little relation to the actual code).

If enough people really want it, the let-binding around ess-eval-visibly-p
in ob-R.el can be removed, but IMO there should be an understanding that:
1) This won’t make all evaluation echo line-by-line.
2) Preserving line-by-line echoing mustn’t be allowed to block the
   evolution of other features that are incompatible with it.

For your use case, I would suggest adding print() calls in strategic
places in your long-running code, which will appear in the R buffer to
let you know how it’s progressing.

-- 
Aaron Ecay

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Evaluating R source code line by line
  2014-12-13 19:38     ` Aaron Ecay
@ 2014-12-15 22:58       ` Vikas Rawal
  2014-12-16 16:32         ` Andreas Leha
  0 siblings, 1 reply; 7+ messages in thread
From: Vikas Rawal @ 2014-12-15 22:58 UTC (permalink / raw)
  To: Aaron Ecay; +Cc: Daniele Pizzolli, org-mode mailing list

[-- Attachment #1: Type: text/plain, Size: 318 bytes --]

> 
> 
> For your use case, I would suggest adding print() calls in strategic
> places in your long-running code, which will appear in the R buffer to
> let you know how it’s progressing.
> 

I don’t quite understand everything you wrote. But this would be helpful for my test case. Will use.

Thanks.

Vikas

[-- Attachment #2: Type: text/html, Size: 1250 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Evaluating R source code line by line
  2014-12-15 22:58       ` Vikas Rawal
@ 2014-12-16 16:32         ` Andreas Leha
  2014-12-16 18:43           ` Andreas Leha
  0 siblings, 1 reply; 7+ messages in thread
From: Andreas Leha @ 2014-12-16 16:32 UTC (permalink / raw)
  To: emacs-orgmode

Hi Vikas,


Vikas Rawal <vikaslists@agrarianresearch.org> writes:
>     
>     
>     
>     For your use case, I would suggest adding print() calls in
>     strategic
>     places in your long-running code, which will appear in the R
>     buffer to
>     let you know how it’s progressing.
>     
>     
>
> I don’t quite understand everything you wrote. But this would be
> helpful for my test case. Will use.
>
> Thanks.
>
> Vikas

I am joining late.  I suspect that this can be configured on the ESS
side rather than on orgmode's side.

Take a look at ess-eval-visibly (but beware the performance loss).

Andreas

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Evaluating R source code line by line
  2014-12-16 16:32         ` Andreas Leha
@ 2014-12-16 18:43           ` Andreas Leha
  0 siblings, 0 replies; 7+ messages in thread
From: Andreas Leha @ 2014-12-16 18:43 UTC (permalink / raw)
  To: emacs-orgmode

Hi,

I stand corrected.  (Should test before I send...)

Here is a reply I received from Ista which -- I think -- did not make it
to the list:


On Tue, Dec 16, 2014 at 11:32 AM, Andreas Leha
<andreas.leha@med.uni-goettingen.de> wrote:
> Hi Vikas,
>
>
> Vikas Rawal <vikaslists@agrarianresearch.org> writes:
>>
>>
>>
>>     For your use case, I would suggest adding print() calls in
>>     strategic
>>     places in your long-running code, which will appear in the R
>>     buffer to
>>     let you know how it’s progressing.
>>
>>
>>
>> I don’t quite understand everything you wrote. But this would be
>> helpful for my test case. Will use.
>>
>> Thanks.
>>
>> Vikas
>
> I am joining late.  I suspect that this can be configured on the ESS
> side rather than on orgmode's side.
>
> Take a look at ess-eval-visibly (but beware the performance loss).

I thought so too, but I don't think that's the case. This affects how
org-babel behaves with :results output, but not the behavior with
:results value. At least that's the case here with org 8.2.10

Running these two examples:

#+BEGIN_SRC R :results value :session *R*
  a <- 1
  b <- 2
  print(a + b)
#+END_SRC

#+RESULTS:
: 3

#+BEGIN_SRC R :results output :session *R*
  a <- 1
  b <- 2
  print(a + b)
#+END_SRC

#+RESULTS:
: [1] 3


I see

>>
+ + [1] 3
>>

for the first one and

> a <- 1
b <- 2
print(a + b)
'org_babel_R_eoe'
a <- 1
> b <- 2
> print(a + b)
[1] 3
> 'org_babel_R_eoe'
[1] "org_babel_R_eoe"
>

for the second one. I have ess-eval-visibly set to t.

Best,
Ista

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-12-16 18:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-13  2:26 Evaluating R source code line by line Vikas Rawal
2014-12-13 10:12 ` Daniele Pizzolli
2014-12-13 13:18   ` Vikas Rawal
2014-12-13 19:38     ` Aaron Ecay
2014-12-15 22:58       ` Vikas Rawal
2014-12-16 16:32         ` Andreas Leha
2014-12-16 18:43           ` Andreas Leha

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).