emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Exporting output and graphics from R


From: Rainer M. Krug
Subject: Re: [O] Exporting output and graphics from R
Date: Thu, 30 May 2013 15:37:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Feng Shu <address@hidden> writes:

> address@hidden (Rainer M. Krug) writes:
>
>> "Sebastien Vauban" <address@hidden>
>> writes:
>>
>>> Hi SabreWolfy,
>>>
>>> SabreWolfy wrote:
>>>> When the following code is evaluated or exported, only the link to
>>>> "testout.png" appears in the RESULTS section.
>>>>
>>>> #+BEGIN_SRC R :results output graphics :file testout.png :exports both
>>>> plot(1:10, 1:10)
>>>> x <- 1:10
>>>> library(ascii)
>>>> options(asciiType = "org")
>>>> ascii(x)
>>>> #+END_SRC
>>>
>>> Removing `output' here should solve the above point.
>>>
>>>> When this code is evaluated, the value of "x" appears in the RESULTS:
>>>>
>>>> #+BEGIN_SRC R :results output :exports both
>>>> x <- 1:10
>>>> library(ascii)
>>>> options(asciiType = "org")
>>>> ascii(x)
>>>> #+END_SRC
>>>>
>>>> How can I get the first example to output both graphics and ascii output?
>>>
>>> AFAICT, you can't have both at the same time. Do you have a real use case 
>>> for
>>> this?
>>
>> Not directly, But I used the following approach to include pdf as well
>> as jpeg ion a document.
>>
>> You simply have to create your graph in R and then include a link in org
>> manually:
>>
>> ,----
>> | #+BEGIN_SRC R :results output :exports both
>> | png("testout.png")
>> | plot(1:10, 1:10)
>> | dev.off()
>> | x <- 1:10
>> | library(ascii)
>> | options(asciiType = "org")
>> | ascii(x)          
>> | #+END_SRC
>> | 
>> | 
>> | [[./testout.png]]
>> `----
>>
>
>
>  #+BEGIN_SRC R :results output :exports both
>  pngname <- "testout.png"
>  png(pngname)
>  plot(1:10, 1:10)
>  dev.off()
>  x <- 1:10
>  paste("[[./", pngname, "]]",sep="")
>  #+END_SRC
>

There are many ways to kill a bird - but you are right - this one is
nicer. You could even use an org variable to specify the file name.

Cheers,

Rainer


>
>
>> you will get the code, result (output) and the graph (tested on export
>> to pdf).
>>
>> Cheers,
>>
>> Rainer
>>
>>>
>>> If really needed, you can define your code once, wrap it with some value for
>>> the ":results" header, and "copy" it somewhere else via Noweb's facility,
>>> where it can be evaluated under other values for the ":results" header.
>>>
>>>> I'm using Org 7.9.2.
>>>
>>> Try upgrading now to Org 8 so that you fiddle only once with the export
>>> variables -- which changed, even if similar, between Org 7.9 and Org 8.
>>>
>>> Best regards,
>>>   Seb
>> <#secure method=pgpmime mode=sign>
>>
>
<#secure method=pgpmime mode=sign>

-- 
Rainer M. Krug




reply via email to

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