* [babel] Emitting both text & graphics output
@ 2011-03-22 20:02 Ken.Williams
2011-03-22 21:06 ` Mikhail Titov
2011-03-22 23:28 ` suvayu ali
0 siblings, 2 replies; 4+ messages in thread
From: Ken.Williams @ 2011-03-22 20:02 UTC (permalink / raw)
To: emacs-orgmode
Hi,
Suppose I have a source block like the following, which both 'print's some
text output and 'plot's to a graphics device:
------------------------------
#+begin_src R :file tp.png :exports both :results output graphics
dat <- matrix(runif(12), 6, 2)
print(dat)
plot(dat)
#+end_src
------------------------------
I can't seem to get the print() output to display, either by exporting to
HTML or by simple evaluation of the code block.
'C-c C-c' results in the following 'results' section:
------------------------------
#+results:
[[file:tp.png]]
------------------------------
And 'C-c C-e b' results in HTML output like this:
------------------------------
<pre class="src src-R">dat <span style="color: #008b8b;"><-</span>
matrix(runif(12), 6, 2)
print(dat)
plot(dat)
</pre>
<p>
<img src="tp.png" alt="tp.png" />
</p>
------------------------------
Neither of those have the actual printed matrix output, which would be
something like this:
------------------------------
#+begin_src R :exports both :results output
dat <- matrix(runif(12), 6, 2)
print(dat)
#+end_src
#+results:
: [,1] [,2]
: [1,] 0.3675202 0.1995134
: [2,] 0.9221087 0.1225686
: [3,] 0.6534830 0.6986238
: [4,] 0.3523151 0.1299406
: [5,] 0.7207582 0.5494278
: [6,] 0.3665547 0.6328452
------------------------------
Any clues? Thanks.
--
Ken Williams
Senior Research Scientist
Thomson Reuters
http://labs.thomsonreuters.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [babel] Emitting both text & graphics output
2011-03-22 20:02 [babel] Emitting both text & graphics output Ken.Williams
@ 2011-03-22 21:06 ` Mikhail Titov
2011-03-22 23:28 ` suvayu ali
1 sibling, 0 replies; 4+ messages in thread
From: Mikhail Titov @ 2011-03-22 21:06 UTC (permalink / raw)
To: Ken.Williams, emacs-orgmode
I'm just a newbie user of org & babel, but as a workaround I'd split it into
several blocks and use session based work. For instance I have the following
in my dot emacs:
(setq org-babel-default-header-args:R
'((:results . "output") (:session . "*R*")))
This way I can always see what is going on within ESS in *R* buffer and all
variables are preserved.
Mikhail
> -----Original Message-----
> From: emacs-orgmode-bounces+mlt=gmx.us@gnu.org [mailto:emacs-orgmode-
> bounces+mlt=gmx.us@gnu.org] On Behalf Of Ken.Williams@thomsonreuters.com
> Sent: Tuesday, March 22, 2011 3:03 PM
> To: emacs-orgmode@gnu.org
> Subject: [O] [babel] Emitting both text & graphics output
>
> Hi,
>
> Suppose I have a source block like the following, which both 'print's
> some
> text output and 'plot's to a graphics device:
>
> ------------------------------
> #+begin_src R :file tp.png :exports both :results output graphics
> dat <- matrix(runif(12), 6, 2)
> print(dat)
> plot(dat)
> #+end_src
> ------------------------------
>
>
>
> I can't seem to get the print() output to display, either by exporting
> to
> HTML or by simple evaluation of the code block.
>
> 'C-c C-c' results in the following 'results' section:
>
> ------------------------------
> #+results:
> [[file:tp.png]]
> ------------------------------
>
>
>
> And 'C-c C-e b' results in HTML output like this:
>
> ------------------------------
> <pre class="src src-R">dat <span style="color: #008b8b;"><-</span>
> matrix(runif(12), 6, 2)
> print(dat)
> plot(dat)
> </pre>
> <p>
> <img src="tp.png" alt="tp.png" />
> </p>
>
> ------------------------------
>
>
>
> Neither of those have the actual printed matrix output, which would be
> something like this:
>
> ------------------------------
> #+begin_src R :exports both :results output
> dat <- matrix(runif(12), 6, 2)
> print(dat)
> #+end_src
>
> #+results:
> : [,1] [,2]
> : [1,] 0.3675202 0.1995134
> : [2,] 0.9221087 0.1225686
> : [3,] 0.6534830 0.6986238
> : [4,] 0.3523151 0.1299406
> : [5,] 0.7207582 0.5494278
> : [6,] 0.3665547 0.6328452
> ------------------------------
>
>
>
>
> Any clues? Thanks.
>
>
>
> --
> Ken Williams
> Senior Research Scientist
> Thomson Reuters
> http://labs.thomsonreuters.com
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [babel] Emitting both text & graphics output
2011-03-22 20:02 [babel] Emitting both text & graphics output Ken.Williams
2011-03-22 21:06 ` Mikhail Titov
@ 2011-03-22 23:28 ` suvayu ali
2011-03-23 1:20 ` Nick Dokos
1 sibling, 1 reply; 4+ messages in thread
From: suvayu ali @ 2011-03-22 23:28 UTC (permalink / raw)
To: Ken.Williams; +Cc: emacs-orgmode
On Tue, Mar 22, 2011 at 1:02 PM, <Ken.Williams@thomsonreuters.com> wrote:
> ------------------------------
> #+begin_src R :file tp.png :exports both :results output graphics
> dat <- matrix(runif(12), 6, 2)
> print(dat)
> plot(dat)
> #+end_src
> ------------------------------
>
>
>
> I can't seem to get the print() output to display, either by exporting to
> HTML or by simple evaluation of the code block.
Exporting to HTML includes a plot for me. Are you sure you activated R properly?
This is my settings for babel,
https://github.com/suvayu/.emacs.d/blob/master/lisp/org-mode-settings.el#L282
--
Suvayu
Open source is the future. It sets us free.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [babel] Emitting both text & graphics output
2011-03-22 23:28 ` suvayu ali
@ 2011-03-23 1:20 ` Nick Dokos
0 siblings, 0 replies; 4+ messages in thread
From: Nick Dokos @ 2011-03-23 1:20 UTC (permalink / raw)
To: suvayu ali; +Cc: Ken.Williams, nicholas.dokos, emacs-orgmode
suvayu ali <fatkasuvayu+linux@gmail.com> wrote:
> On Tue, Mar 22, 2011 at 1:02 PM, <Ken.Williams@thomsonreuters.com> wrote:
> > ------------------------------
> > #+begin_src R :file tp.png :exports both :results output graphics
> > dat <- =A0matrix(runif(12), 6, 2)
> > print(dat)
> > plot(dat)
> > #+end_src
> > ------------------------------
> >
> >
> >
> > I can't seem to get the print() output to display, either by exporting to
> > HTML or by simple evaluation of the code block.
>
>
> Exporting to HTML includes a plot for me. Are you sure you activated R prop=
> erly?
>
... but it doesn't include the print(dat) output. That's what the OP wanted
I think.
Nick
PS. the session trick that Mikhail Titov suggested works well:
--8<---------------cut here---------------start------------->8---
* Foo
#+begin_src R :session *R* :exports both :results output
dat <- matrix(runif(12), 6, 2)
print(dat)
#+end_src
#+results:
: [,1] [,2]
: [1,] 0.3459181 0.04018971
: [2,] 0.9300838 0.75353098
: [3,] 0.4234347 0.51248641
: [4,] 0.3713377 0.23556420
: [5,] 0.2572491 0.73720994
: [6,] 0.7233642 0.58195861
#+begin_src R :session *R* :exports both :results graphics :file tp.png
plot(dat)
#+end_src
#+results:
[[file:tp.png]]
--8<---------------cut here---------------end--------------->8---
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-03-23 1:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-22 20:02 [babel] Emitting both text & graphics output Ken.Williams
2011-03-22 21:06 ` Mikhail Titov
2011-03-22 23:28 ` suvayu ali
2011-03-23 1:20 ` Nick Dokos
Code repositories for project(s) associated with this public 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).