emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Plotting with R
@ 2021-08-15 13:17 Roger Mason
  2021-08-15 13:31 ` Pedro Bruel
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Mason @ 2021-08-15 13:17 UTC (permalink / raw)
  To: orgmode

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Plotting with R
  2021-08-15 13:17 Plotting with R Roger Mason
@ 2021-08-15 13:31 ` Pedro Bruel
  2021-08-15 14:14   ` Roger Mason
  0 siblings, 1 reply; 4+ messages in thread
From: Pedro Bruel @ 2021-08-15 13:31 UTC (permalink / raw)
  To: Roger Mason; +Cc: orgmode

[-- Attachment #1: Type: text/plain, Size: 1541 bytes --]

Hi Roger,

There's a typo on your source block header, it should be "output graphics",
this would probably produce the output you're getting now.

Thanks,
Pedro


Le dim. 15 août 2021 à 10:17, Roger Mason <rmason@mun.ca> a écrit :

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

[-- Attachment #2: Type: text/html, Size: 2134 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Plotting with R
  2021-08-15 13:31 ` Pedro Bruel
@ 2021-08-15 14:14   ` Roger Mason
  2021-08-15 14:34     ` Pedro Bruel
  0 siblings, 1 reply; 4+ messages in thread
From: Roger Mason @ 2021-08-15 14:14 UTC (permalink / raw)
  To: orgmode

Hello Pedro,

Pedro Bruel writes:

> There's a typo on your source block header, it should be "output graphics",
> this would probably produce the output you're getting now.

Thank you!  You saved my sanity!

Roger


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Plotting with R
  2021-08-15 14:14   ` Roger Mason
@ 2021-08-15 14:34     ` Pedro Bruel
  0 siblings, 0 replies; 4+ messages in thread
From: Pedro Bruel @ 2021-08-15 14:34 UTC (permalink / raw)
  To: Roger Mason; +Cc: orgmode

[-- Attachment #1: Type: text/plain, Size: 339 bytes --]

No problem!

Le dim. 15 août 2021 à 11:14, Roger Mason <rmason@mun.ca> a écrit :

> Hello Pedro,
>
> Pedro Bruel writes:
>
> > There's a typo on your source block header, it should be "output
> graphics",
> > this would probably produce the output you're getting now.
>
> Thank you!  You saved my sanity!
>
> Roger
>
>

[-- Attachment #2: Type: text/html, Size: 652 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-15 14:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-15 13:17 Plotting with R Roger Mason
2021-08-15 13:31 ` Pedro Bruel
2021-08-15 14:14   ` Roger Mason
2021-08-15 14:34     ` Pedro Bruel

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).