emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Problem with babel and R + lattice
@ 2012-03-08 20:40 John Hendy
  2012-03-08 20:52 ` John Hendy
  0 siblings, 1 reply; 4+ messages in thread
From: John Hendy @ 2012-03-08 20:40 UTC (permalink / raw)
  To: emacs-orgmode

I have an R block like so:

#+begin_src R

library(lattice)
library(tikzDevice)

=bunch of code=

barchart(side$name~side$x2,groups=side$type,horiz=T,
         xlim=c(0,0.75),col=c("lightblue","yellow"),xlab="Product
Performance (2-box)")

dev.off()
tools::texi2dvi("bar-2b.tex",pdf=T)

#+end_src

The resultant tex file is empty where the tikz code should be and
texi2dvi fails. Any suggestions? If I change my plot to base graphics
with barplot, it works. I'm thinking this is a lattice/babel issue?


Thanks for any input,
John

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with babel and R + lattice
  2012-03-08 20:40 Problem with babel and R + lattice John Hendy
@ 2012-03-08 20:52 ` John Hendy
  2012-03-09  8:41   ` Rainer M Krug
  0 siblings, 1 reply; 4+ messages in thread
From: John Hendy @ 2012-03-08 20:52 UTC (permalink / raw)
  To: emacs-orgmode

Drat. I meant to add that when I run the code exactly as I have it
from R directly, it works. I literally copy and paste my org-mode
babel block code line by line into a terminal and obtain the proper
output via tikz. *That's* the perplexing part. What would be working
directly from R and not from Org-mode?

For reference, I've generated plenty of stuff just like this via
org-mode/babel. Come to think of it, even another lattice plot.

Not sure how to pinpoint what's goofy about this specific plot.

John

On Thu, Mar 8, 2012 at 2:40 PM, John Hendy <jw.hendy@gmail.com> wrote:
> I have an R block like so:
>
> #+begin_src R
>
> library(lattice)
> library(tikzDevice)
>
> =bunch of code=
>
> barchart(side$name~side$x2,groups=side$type,horiz=T,
>         xlim=c(0,0.75),col=c("lightblue","yellow"),xlab="Product
> Performance (2-box)")
>
> dev.off()
> tools::texi2dvi("bar-2b.tex",pdf=T)
>
> #+end_src
>
> The resultant tex file is empty where the tikz code should be and
> texi2dvi fails. Any suggestions? If I change my plot to base graphics
> with barplot, it works. I'm thinking this is a lattice/babel issue?
>
>
> Thanks for any input,
> John

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with babel and R + lattice
  2012-03-08 20:52 ` John Hendy
@ 2012-03-09  8:41   ` Rainer M Krug
  2012-03-09 14:04     ` John Hendy
  0 siblings, 1 reply; 4+ messages in thread
From: Rainer M Krug @ 2012-03-09  8:41 UTC (permalink / raw)
  To: John Hendy; +Cc: emacs-orgmode

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 08/03/12 21:52, John Hendy wrote:
> Drat. I meant to add that when I run the code exactly as I have it from R directly, it works. I
> literally copy and paste my org-mode babel block code line by line into a terminal and obtain
> the proper output via tikz. *That's* the perplexing part. What would be working directly from R
> and not from Org-mode?
> 
> For reference, I've generated plenty of stuff just like this via org-mode/babel. Come to think
> of it, even another lattice plot.
> 
> Not sure how to pinpoint what's goofy about this specific plot.
> 
> John
> 
> On Thu, Mar 8, 2012 at 2:40 PM, John Hendy <jw.hendy@gmail.com> wrote:
>> I have an R block like so:
>> 
>> #+begin_src R
>> 
>> library(lattice) library(tikzDevice)
>> 
>> =bunch of code=
>> 
>> barchart(side$name~side$x2,groups=side$type,horiz=T, 
>> xlim=c(0,0.75),col=c("lightblue","yellow"),xlab="Product Performance (2-box)")
>> 
>> dev.off() tools::texi2dvi("bar-2b.tex",pdf=T)
>> 
>> #+end_src
>> 
>> The resultant tex file is empty where the tikz code should be and texi2dvi fails. Any
>> suggestions? If I change my plot to base graphics with barplot, it works. I'm thinking this
>> is a lattice/babel issue?

As with ggplot, you have to print your plot (if I remember correctly), i.e:

print(barchart(...))

Cheers,

Rainer

>> 
>> 
>> Thanks for any input, John
> 


- -- 
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys.
(Germany)

Centre of Excellence for Invasion Biology
Stellenbosch University
South Africa

Tel :       +33 - (0)9 53 10 27 44
Cell:       +33 - (0)6 85 62 59 98
Fax :       +33 - (0)9 58 10 27 44

Fax (D):    +49 - (0)3 21 21 25 22 44

email:      Rainer@krugs.de

Skype:      RMkrug
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk9ZwlcACgkQoYgNqgF2egqMewCfar+JxC9uV9p1O2IYVVYcqyeM
7/4AnRLp8gYqSDe/74D9helafqNR5Vgt
=aDVb
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Problem with babel and R + lattice
  2012-03-09  8:41   ` Rainer M Krug
@ 2012-03-09 14:04     ` John Hendy
  0 siblings, 0 replies; 4+ messages in thread
From: John Hendy @ 2012-03-09 14:04 UTC (permalink / raw)
  To: R.M.Krug; +Cc: emacs-orgmode

On Fri, Mar 9, 2012 at 2:41 AM, Rainer M Krug <r.m.krug@gmail.com> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 08/03/12 21:52, John Hendy wrote:
>> Drat. I meant to add that when I run the code exactly as I have it from R directly, it works. I
>> literally copy and paste my org-mode babel block code line by line into a terminal and obtain
>> the proper output via tikz. *That's* the perplexing part. What would be working directly from R
>> and not from Org-mode?
>>
>> For reference, I've generated plenty of stuff just like this via org-mode/babel. Come to think
>> of it, even another lattice plot.
>>
>> Not sure how to pinpoint what's goofy about this specific plot.
>>
>> John
>>
>> On Thu, Mar 8, 2012 at 2:40 PM, John Hendy <jw.hendy@gmail.com> wrote:
>>> I have an R block like so:
>>>
>>> #+begin_src R
>>>
>>> library(lattice) library(tikzDevice)
>>>
>>> =bunch of code=
>>>
>>> barchart(side$name~side$x2,groups=side$type,horiz=T,
>>> xlim=c(0,0.75),col=c("lightblue","yellow"),xlab="Product Performance (2-box)")
>>>
>>> dev.off() tools::texi2dvi("bar-2b.tex",pdf=T)
>>>
>>> #+end_src
>>>
>>> The resultant tex file is empty where the tikz code should be and texi2dvi fails. Any
>>> suggestions? If I change my plot to base graphics with barplot, it works. I'm thinking this
>>> is a lattice/babel issue?
>
> As with ggplot, you have to print your plot (if I remember correctly), i.e:
>
> print(barchart(...))

I stumbled on this, too but hadn't posted back to the list yet. What
got me on the track to the solution was copying my babel block code
into an R source file and trying to do = > source("path/to/file")=
directly from R. That wasn't working either, so I knew it was
something I was doing and not org. I found the R faq which said that
source files don't generate output for everything unless you tell them
to print() :)

Thanks!
John


>
> Cheers,
>
> Rainer
>
>>>
>>>
>>> Thanks for any input, John
>>
>
>
> - --
> Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys.
> (Germany)
>
> Centre of Excellence for Invasion Biology
> Stellenbosch University
> South Africa
>
> Tel :       +33 - (0)9 53 10 27 44
> Cell:       +33 - (0)6 85 62 59 98
> Fax :       +33 - (0)9 58 10 27 44
>
> Fax (D):    +49 - (0)3 21 21 25 22 44
>
> email:      Rainer@krugs.de
>
> Skype:      RMkrug
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk9ZwlcACgkQoYgNqgF2egqMewCfar+JxC9uV9p1O2IYVVYcqyeM
> 7/4AnRLp8gYqSDe/74D9helafqNR5Vgt
> =aDVb
> -----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-03-09 14:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-08 20:40 Problem with babel and R + lattice John Hendy
2012-03-08 20:52 ` John Hendy
2012-03-09  8:41   ` Rainer M Krug
2012-03-09 14:04     ` John Hendy

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).