emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [babel] suggestion: wrap creation of graphics into try() block


From: Eric Schulte
Subject: Re: [O] [babel] suggestion: wrap creation of graphics into try() block
Date: Mon, 20 Jan 2014 11:38:02 -0700
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

>
> I will check it a little bit longer and see that I can display the
> error message in the dummy graphic. Should have it by tomorrow.
>

Sounds good.  Alternately, maybe you could get the R process to fail and
print an error to STDERR so that the export will stop immediately and
inform the user of the error.

>
> I'll send you the patch then.
>

Sounds great, thanks.

>
> This is the first time I really work with patches - I assume "git
> diff" will give me the patch you need?
>

The best would be to create the patch with git format-patch, see
http://orgmode.org/worg/org-contribute.html#sec-4-2.

If the patch changes more than 10 lines, you'll need to fill out the FSF
copyright assignment paperwork.

Thanks,

>
> Cheers,
>
> Rainer
>
>>
>> Thanks,
>>
>>>
>>> If somebody could look if this makes sense? (defun
>>> org-babel-expand-body:R (body params &optional graphics-file)
>>> "Expand BODY according to PARAMS, return the expanded body." (let
>>> ((graphics-file (or graphics-file
>>> (org-babel-R-graphical-output-file params)))) (mapconcat
>>> #'identity (let ((inside (append (when (cdr (assoc :prologue
>>> params)) (list (cdr (assoc :prologue params))))
>>> (org-babel-variable-assignments:R params) (list body) (when (cdr
>>> (assoc :epilogue params)) (list (cdr (assoc :epilogue
>>> params))))))) (if graphics-file (append (list
>>> (org-babel-R-construct-graphics-device-call graphics-file
>>> params)) inside ;; my edits (list "},error=function(e){plot(-1:1,
>>> -1:1, type='n'); text(0,0,'DUMMY')}); dev.off()")) inside)) ;;
>>> end "\n")))
>>>
>>>
>>>
>>> and
>>>
>>> (format "%s(%s=\"%s\"%s%s%s); tryCatch({" device filearg out-file
>>> args (if extra-args "," "") (or extra-args ""))))
>>>
>>> in org-babel-R-construct-graphics-device-call
>>>
>>> It is working with the Dummy.
>>>
>>> Could somebody please check if this is working?
>>>
>>> I am leaving my changes and will see during my work if it is
>>> fine.
>>>
>>> Cheers,
>>>
>>> Rainer
>>>
>>>
>>>>
>>>>>
>>>>> If the code block which should create the graph would be
>>>>> wrapped into a try() block, so that it would look like the
>>>>> following:
>>>>>
>>>>> try( { pdf("./Correlation_1.pdf") IFN.mean <-
>>>>> load.IFN.mean() grid <- load.grid.CASTANEA.average()
>>>>> image(IFN.mean) } ) dev.off()
>>>>>
>>>>> The device would be closed even if an error occurred during
>>>>> the execution of the code.
>>>>>
>>>>> But still, when  exporting to pdf, the call to pdflatex fails
>>>>> as only a empty pdf is available. So it becomes necessary to
>>>>> go through the pdf log to identify the graphs which failed.
>>>>>
>>>>> In this case it would be useful, to have a placeholder grah
>>>>> in the final pdf, so that one can see which graphs did not
>>>>> work.
>>>>>
>>>>> In addition, this could be used as placeholders (well - they
>>>>> are placeholders) for to be created graphs, while the text
>>>>> has already been written.
>>>>>
>>>>> So my second suggestion would be to include a placeholder
>>>>> image, which would be used if the generation of the actual
>>>>> graph fails. It would be great (but not necessary) if the
>>>>> actual error message would be in the image.
>>>>
>>>> Such an place holder image would be great, indeed.
>>>>
>>>>
>>>> Thanks for bringing this up!
>>>>
>>>> Regards, Andreas
>>>>
>>>>
>>>
>>> -- Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc
>>> (Conservation Biology, UCT), Dipl. Phys. (Germany)
>>>
>>> Centre of Excellence for Invasion Biology Stellenbosch
>>> University South Africa
>>>
>>> Tel :       +33 - (0)9 53 10 27 44 Cell:       +33 - (0)6 85 62
>>> 59 98 Fax :       +33 - (0)9 58 10 27 44
>>>
>>> Fax (D):    +49 - (0)3 21 21 25 22 44
>>>
>>> email:      address@hidden
>>>
>>> Skype:      RMkrug
>>
>
> --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation
> Biology, UCT), Dipl. Phys. (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax :       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      address@hidden
>
> Skype:      RMkrug

-- 
Eric Schulte
https://cs.unm.edu/~eschulte
PGP: 0x614CA05D



reply via email to

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