From mboxrd@z Thu Jan 1 00:00:00 1970 From: Feng Shu Subject: Re: org-babel R output table with plot Date: Tue, 25 Mar 2014 08:00:06 +0800 Message-ID: <87mwgf87w9.fsf@news.tumashu-localhost.org> References: <87txan8vvj.fsf@news.tumashu-localhost.org> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:55714) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSEsG-0003eR-D3 for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 20:05:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WSEsA-00029g-KF for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 20:05:48 -0400 Received: from plane.gmane.org ([80.91.229.3]:59634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WSEsA-00029Y-5M for emacs-orgmode@gnu.org; Mon, 24 Mar 2014 20:05:42 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1WSEs9-0000Zl-6c for emacs-orgmode@gnu.org; Tue, 25 Mar 2014 01:05:41 +0100 Received: from 120.4.245.127 ([120.4.245.127]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Mar 2014 01:05:41 +0100 Received: from tumashu by 120.4.245.127 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 25 Mar 2014 01:05:41 +0100 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: emacs-orgmode@gnu.org John Hendy writes: > 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? > It just suit my need, but I want to know more simper solution, which let me type less code. > > 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: >> >> >> -- >> --