From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Charles C. Berry" Subject: Re: ob-R, problem with try/catch Date: Thu, 23 Apr 2015 09:13:55 -0700 Message-ID: References: <83477C11-94B6-467B-8CD5-77976FE83C31@gmail.com> Mime-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="0-991706613-1429804650=:434" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55345) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlJln-0004Kl-Vq for emacs-orgmode@gnu.org; Thu, 23 Apr 2015 12:14:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YlJlj-0000HI-Km for emacs-orgmode@gnu.org; Thu, 23 Apr 2015 12:14:31 -0400 Received: from iport-acv6-out.ucsd.edu ([132.239.0.13]:34077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YlJlj-0000Gu-7s for emacs-orgmode@gnu.org; Thu, 23 Apr 2015 12:14:27 -0400 In-Reply-To: <83477C11-94B6-467B-8CD5-77976FE83C31@gmail.com> Content-ID: 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 , "Thomas S. Dye" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --0-991706613-1429804650=:434 Content-Type: TEXT/PLAIN; CHARSET=ISO-8859-15; format=flowed Content-Transfer-Encoding: 8BIT Content-ID: On Wed, 22 Apr 2015, Rainer M Krug wrote: > > > Envoyé de mon iPhone > >> Le 23 avr. 2015 à 04:23, Charles C. Berry a écrit : >> >>> On Wed, 22 Apr 2015, Thomas S. Dye wrote: >>> >>> Aloha all, >>> >>> Prior to eaa3a761dae, when working in a session, I was able to run this >>> R source code block without problems: >>> >>> ,----------------------------------------- >>> | #+header: :file r/adze_wt_log.pdf >>> | #+header: :results output graphics >>> | #+header: :width 4 :height 3 >>> | #+begin_src R >>> | g <- ggplot(x, aes(x = weight)) >>> | g + geom_histogram(aes(y=..density..)) >> >> ## Try this: >> >> print( g + geom_histogram(aes(y=..density..)) ) # before rm(g). >> >> >>> | rm(g) >>> | #+end_src >>> `----------------------------------------- >>> >>> 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. `:results output' will return the autoprinted values. Without tryCatch it works. > 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. Here are two blocks that differ in using tryCatch. The first produces an empty, malformed pdf. The second produces a valid pdf. If you comment out the `invisible()' line in the first, then both will produce similar valid pdf's. #+header: :file nada.pdf #+header: :results output graphics #+header: :width 4 :height 3 #+begin_src R require(ggplot2) df <- data.frame(gp = factor(rep(letters[1:3], each = 10)), y = rnorm(30)) ggplot(df, aes(x = gp, y = y)) + geom_point() invisible() #+end_src #+BEGIN_SRC R :results output require(ggplot2) pdf(file="aok.pdf",width=4,height=3) df <- data.frame(gp = factor(rep(letters[1:3], each = 10)), y = rnorm(30)) ggplot(df, aes(x = gp, y = y)) + geom_point() invisible() dev.off() #+END_SRC HTH, Chuck --0-991706613-1429804650=:434--