emacs-orgmode
[Top][All Lists]
Advanced

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

Refresher on including R/ggplot2 output via latex/pdf?


From: John Hendy
Subject: Refresher on including R/ggplot2 output via latex/pdf?
Date: Sun, 27 Oct 2019 23:16:00 -0500

Greetings,

I used to use orgmode + R/ggplot2 for some time, but for various
reasons I've been using python almost exclusively for a couple years.
I just went to use what I think is how I used to include ggplot2
results in PDF experts, but it's not working.

In referring to the documentation, this is listed as an example:
- https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html#org046a0ff

* does produce a file, by using :results output
#+begin_src R :file 3.png :results output graphics
library(lattice)
xyplot(1:10 ~ 1:10)
#+end_src

My test file:
-----
* test

#+begin_src R :results output graphics :exports results :file foo.png
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'm using emacs -Q, followed by M-x load-file RET path/to/min-config:
-----
;; set load paths
;; set load dirs and global config options
(add-to-list 'load-path "~/.elisp/org/lisp/")
(add-to-list 'load-path "~/.elisp/org/contrib/lisp/")
(add-to-list 'load-path "~/.elisp/ess/lisp/")

(require 'ess-site)

; setup babel languages
(org-babel-do-load-languages
 'org-babel-load-languages
 '((R . t)))
-----

M-x org-version: Org mode version 9.2.4 (release_9.2.4-381-g226363 @
/home/jwhendy/.elisp/org/lisp/)

When I run the code, the #+RESULTS: output is just blank. foo.png *is*
generated, but the file link ([[foo.png]]) I'd expect is not getting
inserted. It also, unsurprisingly, does not show in the file.

Hmmm. One last hail Mary google incantation before I sent this off
suggests that perhaps it's :results file now? Or :results graphics
file?
- 
https://stackoverflow.com/questions/50054520/python-vs-r-in-org-mode-babel-output-graphics

Thanks for any pointers. I'd be happy to assist with updated
documentation if the earlier link is now outdated/incorrect.


Best regards,
John



reply via email to

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