emacs-orgmode
[Top][All Lists]
Advanced

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

[FR] Org babel: mixing multiple outputs (was: Output of R code block: on


From: Ihor Radchenko
Subject: [FR] Org babel: mixing multiple outputs (was: Output of R code block: only text or plot but not both? And only one "result" can be output?)
Date: Wed, 05 Jun 2024 18:17:08 +0000

"Berry, Charles" <ccberry@health.ucsd.edu> writes:

>> I am trying to have an R code block output both the results of a numerical 
>> expression AND a plot, but if I set up the header arguments to display the 
>> plot, the numerical outcome is not displayed.  A simple example:
>> 
>> #+begin_src R :file example.png :results output graphics file
>>   x <- rnorm(100)
>>   print(mean(x))
>>   hist(x)
>> #+end_src
>> 
>
>
> Babel is a great tool, but has some inherent limitations.

While it is currently not directly possible to get a mix output and
graphics results, this is _not_ inherent limitation.

One can write a patch for ob-R to produce output type that mixes all the
block results, including textual output, graphical output, and any other
perceivable output.

Such patch would be a reasonable addition to babel backends like ob-R or 
ob-python.

> Whilst you can work around this by breaking the above block into
> multiple src blocks, you might have an easier time using ox-ravel
> [1]. Basically, you export your *.org document to one of the
> knitr/Rmarkdown/quarto formats (e.g. *.Rmd) and then render the final
> output using one of those engines. This gives you access to the
> capabilities of any of those engines.  The downside, of course, is
> that you need to learn a bit about the formatting rules in one of them
> to fine tune your final output.
>
> FWIW, I copy and pasted your query to a `*.org` file, exported it to
> `*.Rmd` with the latest ox-ravel version and rendered it as html -
> displaying all the printed output and all three plots. That did not
> need any modifications to your markup.

Thanks for sharing the project!
Although, I would not call going through double export, and producing
html output "easier time".

While we are here, are there any other features you find missing in Org
babel that are present in knitr/Rmarkdown/quarto?

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>



reply via email to

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