emacs-orgmode
[Top][All Lists]
Advanced

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

Plotting with R


From: Roger Mason
Subject: Plotting with R
Date: Sun, 15 Aug 2021 10:47:02 -0230
User-agent: mu4e 1.5.6; emacs 27.2

Hello,

I want graphics output from R:

#+begin_src R :results output grahics file :file coa_vs_a.pdf :exports results 
library(tidyverse)
library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, user="rmason",dbname="test")
rs <- dbSendQuery(con,"with CTE as (select split_part(split_part(lattice_out, 
E'\n', 13), ' ', 18) as c,
 split_part(split_part(lattice_out, E'\n', 11), ' ', 11) as a
 from results where timestamp like '20210814-071%' order by a)
 select cast(a as double precision), cast(c as double precision)/ cast(a as 
float) as coa from CTE;")
df <- fetch(rs)
theplot <- ggplot(df,aes(x=a,y=coa)) + geom_point()
theplot
#+end_src

What I expect is a file 'coa_vs_a.pdf' on my filesystem & a link to it
in the org buffer.  What I get is a file 'Rplots.pdf' and an empty file
'coa_vs_a.pdf' with a link to the latter in the org buffer.

I've searched this topic and I _think_ the invocation above, one of many
I've tried, should work.

GNU Emacs 27.2 (build 1, amd64-portbld-freebsd11.4, X toolkit, cairo
version 1.16.0, Xaw3d scroll bars)

Org mode version 9.2.3 (release_9.2.3-390-gfb5091 @
/home/rmason/.emacs.d/org-git/lisp/)

Thanks for your help.

Roger



reply via email to

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