emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Problem with R source blocks


From: Charles C. Berry
Subject: Re: [O] Problem with R source blocks
Date: Fri, 12 Jun 2015 11:50:09 -0700
User-agent: Alpine 2.11 (OSX 23 2013-08-11)

On Thu, 11 Jun 2015, Thomas S. Dye wrote:

Aloha all,

Recently, some previously working R code (below) stopped working correctly.

It is not possible to produce a graphic without :session.  I get a red
message in the pdf file "arguments imply differing numbers of rows: 86,
79".

With :session, I first get one of two error messages in red in the pdf
file, either "Results must be all atomic, or all data frames" or
"subscript out of bounds".

With the "subscript out of bounds" error, if I run the source code block
again, I get the expected graphic.

With the "Results must be all atomic ..." message, if I re-run the
source code block several times, I see first an error "arguments imply
differing numbers of rows: 67, 60", then on the next run "arguments imply
differing numbers of rows: 86, 79" (like running outside a :session),
then the expected graphic.  Subsequent runs all produce the expected
graphic.

If I jump to the session, then print(g) works as expected, without any
error messages.

I haven't the faintest idea what might be happening, or how to debug.


The error messages are coming from R. cbind will say:

: Error in data.frame(..., check.names = FALSE) :
:   arguments imply differing number of rows: 2, 3

if you try cbind( data.frame(diag(2)), 1:3 )

Also, you are feeding lots of vars to the R src block, so that is a good place to look for trouble.

You could try to instrument `org-babel-R-evaluate-external-process' and see if anything jumps out at you.

But if not, ...

To debug, I'd try to replace your block with one that is utterly self contained - no need for external vars begin passed in from Org mode - and that invokes ggplot2 to produce a result. Once that works, define :var args and print them to a temp file from inside that R src block using

        capture.output(print(your.var1),...,print(your.varK),
                file = "myTemp.Rout")

Once that works, I'd add the first lines of code and print out intermediate values from inside your for() loop, but before the cbind() again using capture.output().

I expect by then the issue should be revealed.


HTH,

Chuck



reply via email to

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