From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: Problem with R source blocks Date: Fri, 12 Jun 2015 11:50:09 -0700 Message-ID: References: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3U2Z-0002gq-Db for emacs-orgmode@gnu.org; Fri, 12 Jun 2015 14:50:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z3U2V-0002JL-QA for emacs-orgmode@gnu.org; Fri, 12 Jun 2015 14:50:54 -0400 Received: from iport-acv2-out.ucsd.edu ([132.239.0.174]:42132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z3U2V-0002C1-Ae for emacs-orgmode@gnu.org; Fri, 12 Jun 2015 14:50:51 -0400 In-Reply-To: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: "Thomas S. Dye" Cc: emacs-orgmode@gnu.org 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