From mboxrd@z Thu Jan 1 00:00:00 1970 From: tsd@tsdye.com (Thomas S. Dye) Subject: Re: ob-R, problem with try/catch Date: Thu, 23 Apr 2015 05:53:08 -1000 Message-ID: References: <83477C11-94B6-467B-8CD5-77976FE83C31@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:50325) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlJRQ-0004Lc-Or for emacs-orgmode@gnu.org; Thu, 23 Apr 2015 11:53:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlJRM-0000vZ-Mp for emacs-orgmode@gnu.org; Thu, 23 Apr 2015 11:53:28 -0400 Received: from gproxy1-pub.mail.unifiedlayer.com ([69.89.25.95]:53820) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1YlJRM-0000ss-Fj for emacs-orgmode@gnu.org; Thu, 23 Apr 2015 11:53:24 -0400 In-Reply-To: <83477C11-94B6-467B-8CD5-77976FE83C31@gmail.com> (Rainer M. Krug's message of "Thu, 23 Apr 2015 07:40:25 +0200") 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: Rainer M Krug Cc: Org-mode , "Charles C. Berry" Aloha Rainer, Rainer M Krug writes: >>> After eaa3a761dae, I get an error and an empty output file. >> >> That commit introduced a tryCatch() wrapper for graphics results. >> >> You probably know that ggplot (or ggplot2) relies on printing of >> objects to produce graphics (see R-FAQ 7.22). >> >> tryCatch(expr,...) evaluates expr and returns its value, which is >> `rm(g)' in your case. But `rm(g)' is not autoprinted, and you get an >> empty file. > > I am not in front of my computer but there must be more, as even > before the commit there should have been empty file for exactly the > same reason. Also, the error is strange. Could you send a small > reproducable example, so that we can see which error you get? Because > if you get an error and an empty file, an error must be in the > tryCatcb block. I'm picking up a project that I last worked on in 2013. I was under the impression that the source code blocks were working at that time, but I guess it is possible that I added the rm() statements after the code blocks were working and didn't realize that the addition broke them. I haven't looked too deeply into the problem, but just assumed that the session expressed in the source code block behaved as if it were entered at the R prompt. In the R session, I see this, which I initially thought was an error: > png(filename="r/buck-shoulder-hist.png",width=400,height=300); tryCatch({ b <- ggplot(x, aes(x=((thickness_shoulder * 100) / mapply(max, width_shoulder_front, width_shoulder_back)))) b + geom_histogram(aes(y=..density..)) + geom_density(weight=2) + xlab("Buck's Shoulder Index") + facet_wrap(~ turner) rm(b) },error=function(e){plot(x=-1:1, y=-1:1, type='n', xlab='', ylab='', axes=FALSE); text(x=0, y=0, labels=e$message, col='red'); paste('ERROR', e$message, sep=' : ')}); dev.off() 'org_babel_R_eoe' + . + null device 1 hth, Tom -- Thomas S. Dye http://www.tsdye.com