From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Hendy Subject: Re: org-babel R output table with plot Date: Mon, 24 Mar 2014 12:36:11 -0500 Message-ID: References: <87txan8vvj.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:58250) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8nL-0001T6-5M for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 13:36:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WS8nF-0001TB-M2 for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 13:36:19 -0400 Received: from mail-ob0-x22d.google.com ([2607:f8b0:4003:c01::22d]:46843) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WS8nF-0001Sk-Ho for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 13:36:13 -0400 Received: by mail-ob0-f173.google.com with SMTP id gq1so6161755obb.32 for ; Mon, 24 Mar 2014 10:36:11 -0700 (PDT) In-Reply-To: <87txan8vvj.fsf@news.tumashu-localhost.org> 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-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Feng Shu Cc: orgmode On Mon, Mar 24, 2014 at 10:22 AM, Feng Shu 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: > > > -- >