emacs-orgmode
[Top][All Lists]
Advanced

[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: Giuseppe Pagnoni
Subject: Re: Output of R code block: only text or plot but not both? And only one "result" can be output?
Date: Fri, 7 Jun 2024 11:10:51 +0200

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?

thanks again
giuseppe

On Wed, Jun 5, 2024 at 8:35 PM Ihor Radchenko <yantar92@posteo.net> wrote:
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>


--
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


reply via email to

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