Ok, I just found out! You need to close the device after each plot:
#+begin_src R :results output raw drawer :dir ./
x <- rnorm(100)
print(mean(x))
png(file="hist1.png")
hist(x)
dev.off()
png(file="hist2.png")
hist(x^2)
dev.off()
print("[[./hist1.png]]")
print("[[./hist2.png]]")
#+end_src
thanks!
On Fri, Jun 7, 2024 at 11:18 AM Ihor Radchenko <[email protected]> wrote:
> Giuseppe Pagnoni <[email protected]> writes:
>
> > Sorry, I just sent you the reply that was meant for Berry's advice :-).
> > Your suggestion also looks very useful, but somehow the png files do not
> > get saved (in the current directory or elsewhere), and I actually do not
> > get any error messages in the R buffer (I also tried to change the file
> > type to jpeg). Any idea why?
>
> Hard to say.
> Try to run my example in command line R repl.
>
> --
> 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>
>
--
Giuseppe Pagnoni
Dip. Scienze Biomediche, Metaboliche e Neuroscienze
Sezione Fisiologia e Neuroscienze
Univ. di Modena e Reggio Emilia
Via Campi 287
I-41125 Modena, Italy
Tel: +39-059-205-5742
Fax: +39-059-205-5363