From: John Hendy <jw.hendy@gmail.com>
To: Feng Shu <tumashu@gmail.com>
Cc: orgmode <emacs-orgmode@gnu.org>
Subject: Re: org-babel R output table with plot
Date: Mon, 24 Mar 2014 12:36:11 -0500 [thread overview]
Message-ID: <CA+M2ft81yjvEgPn85SGcueDw27LNxsU8SAmtK4b0Jv-5=2ET3w@mail.gmail.com> (raw)
In-Reply-To: <87txan8vvj.fsf@news.tumashu-localhost.org>
On Mon, Mar 24, 2014 at 10:22 AM, Feng Shu <tumashu@gmail.com> wrote:
> Hi everyone
>
> I want to R output table with plot, I use a solution below,
> Who can tell me other solutions?
>
I sort of follow the below, but I think it would be more helpful to
describe what you *don't* like about the output below. In other words,
what are you trying to achieve that is not working below?
John
> thanks!
>
> #+begin_src R :results output raw drawer
> require("ascii")
>
> print.org <- function (x, caption)
> {
> print(paragraph(paste("#+CAPTION: ", caption, sep="")),type="org")
> print(ascii(x),type="org")
> }
> plot.org <- function (x, caption)
> {
> pngfile <- paste(caption, ".png", sep="")
> print(paragraph(paste("#+CAPTION: ", caption, sep="")),type="org")
> png(pngfile)
> plot(x)
> dev.off()
> print(paragraph(paste("[[./", pngfile, "]]", sep=""),new=FALSE),type="org")
>
> }
> data <- data.frame(x=c(1,20,100,800),y=c(200,4,5,29))
> print.org(data, "test-table1")
> print.org(data, "test-table2")
> plot.org(data, "test-pic")
>
> #+end_src
>
> #+RESULTS:
> :RESULTS:
>
> #+CAPTION: test-table1
> | | x | y |
> |---+--------+--------|
> | 1 | 1.00 | 200.00 |
> | 2 | 20.00 | 4.00 |
> | 3 | 100.00 | 5.00 |
> | 4 | 800.00 | 29.00 |
>
> #+CAPTION: test-table2
> | | x | y |
> |---+--------+--------|
> | 1 | 1.00 | 200.00 |
> | 2 | 20.00 | 4.00 |
> | 3 | 100.00 | 5.00 |
> | 4 | 800.00 | 29.00 |
>
> #+CAPTION: test-pic
> [[./test-pic.png]]
> :END:
>
>
> --
>
next prev parent reply other threads:[~2014-03-24 17:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-24 15:22 org-babel R output table with plot Feng Shu
2014-03-24 17:36 ` John Hendy [this message]
2014-03-25 0:00 ` Feng Shu
2014-03-27 2:55 ` John Hendy
2014-03-27 4:27 ` Feng Shu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+M2ft81yjvEgPn85SGcueDw27LNxsU8SAmtK4b0Jv-5=2ET3w@mail.gmail.com' \
--to=jw.hendy@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=tumashu@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.