[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Output of R code block: only text or plot but not both? And only one
From: |
Ihor Radchenko |
Subject: |
Re: 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:37:27 +0000 |
Giuseppe Pagnoni <gpagnoni@gmail.com> writes:
> #+begin_src R :file example.png :results output graphics file
> x <- rnorm(100)
> print(mean(x))
> hist(x)
> hist(x^2)
> #+end_src
>
> Here, only the last plot gets displayed. Is it not possible to display
> more than 1 plot?
We currently do not have automatic way to do it, so that the resulting
plots are inserted as previewable file links. However, in addition to
the approach with several :session source blocks proposed by Berry, you
can do it by hand in R:
#+begin_src R :results output raw drawer :dir ./
x <- rnorm(100)
print(mean(x))
png(file="hist1.png")
hist(x)
png(file="hist2.png")
hist(x^2)
print("[[./hist1.png]]")
print("[[./hist2.png]]")
#+end_src
--
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>