From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: Refresher on including R/ggplot2 output via latex/pdf? Date: Sun, 27 Oct 2019 23:40:34 -0500 Message-ID: References: <87sgndlcbe.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:33046) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iOwpj-0004mf-BY for emacs-orgmode@gnu.org; Mon, 28 Oct 2019 00:40:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iOwpi-0002XZ-9s for emacs-orgmode@gnu.org; Mon, 28 Oct 2019 00:40:47 -0400 Received: from mail-qk1-x72b.google.com ([2607:f8b0:4864:20::72b]:43416) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iOwpi-0002XR-4S for emacs-orgmode@gnu.org; Mon, 28 Oct 2019 00:40:46 -0400 Received: by mail-qk1-x72b.google.com with SMTP id a194so7341409qkg.10 for ; Sun, 27 Oct 2019 21:40:45 -0700 (PDT) In-Reply-To: <87sgndlcbe.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: Jack Kamm Cc: emacs-orgmode On Sun, Oct 27, 2019 at 11:31 PM Jack Kamm wrote: > > Your code block looks fine to me. The typical R code block headers I use is as follows: Did you try to reproduce my example, by chance? > :session :results output graphics :file path/to/file.png :exports results :eval never-export Using this: ----- #+begin_src R :session :results output graphics :file foo.png :exports results :eval never-export library(ggplot2) df <- data.frame(x=c(1, 2), y=c(2, 4)) p <- ggplot(df, aes(x = x, y = y)) + geom_point() print(p) #+end_src ----- I get an empty #+RESULTS: header, but no inserted file link. The plot is not in the exported PDF either. If I make it this: ----- #+begin_src R :session :results file graphics :file foo.png :exports results :eval never-export ----- I get the expected results, and the plot is in the output PDF. ----- #+RESULTS: [[file:foo.png]] ----- > One thing I've noticed, if I have an existing graphics device open, it > can mess up plots when executing an org-babel cell. Calling dev.off() a > few times fixes this for me. > > Note I pretty much always use R blocks with the :session argument, > things might be pretty different without it. I usually use :session as well (and have it in my actual document, but left it off for this test case). Still, using your header (minus changing the file path/type) didn't work for me. Thanks for taking a look, John