From: tsd@tsdye.com (Thomas S. Dye)
To: Rainer M Krug <r.m.krug@gmail.com>
Cc: Org-mode <emacs-orgmode@gnu.org>, "Charles C. Berry" <ccberry@ucsd.edu>
Subject: Re: ob-R, problem with try/catch
Date: Thu, 23 Apr 2015 05:53:08 -1000 [thread overview]
Message-ID: <m2egnadeor.fsf@tsdye.com> (raw)
In-Reply-To: <83477C11-94B6-467B-8CD5-77976FE83C31@gmail.com> (Rainer M. Krug's message of "Thu, 23 Apr 2015 07:40:25 +0200")
Aloha Rainer,
Rainer M Krug <r.m.krug@gmail.com> 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
next prev parent reply other threads:[~2015-04-23 15:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-22 22:03 ob-R, problem with try/catch Thomas S. Dye
2015-04-23 2:23 ` Charles C. Berry
2015-04-23 5:40 ` Rainer M Krug
2015-04-23 15:53 ` Thomas S. Dye [this message]
2015-04-23 16:20 ` Rainer M Krug
2015-04-23 16:42 ` Aaron Ecay
2015-04-23 16:13 ` Charles C. Berry
2015-04-23 16:29 ` Rainer M Krug
2015-04-23 17:11 ` Thomas S. Dye
2015-04-23 22:39 ` Aaron Ecay
2015-04-23 23:36 ` Thomas S. Dye
2015-04-26 12:49 ` Nicolas Goaziou
2015-04-26 17:11 ` Charles C. Berry
2015-04-26 17:28 ` Nicolas Goaziou
2015-05-04 8:35 ` Rainer M Krug
2015-05-04 19:03 ` Nicolas Goaziou
2015-04-23 6:35 ` Thomas S. Dye
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=m2egnadeor.fsf@tsdye.com \
--to=tsd@tsdye.com \
--cc=ccberry@ucsd.edu \
--cc=emacs-orgmode@gnu.org \
--cc=r.m.krug@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).