Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-11 Thread Rich Shepard
On Fri, 10 Jul 2015, Yihui Xie wrote: Your LyX example has two problems: 1) We don't have your .RData; 2) You didn't library(reshape) and library(lattice). Hence it is not a self-contained reproducible example. Yihui, I assumed that reading in the *.csv file would create a local .RData

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot() [RESOLVED]

2015-07-11 Thread Rich Shepard
On Fri, 10 Jul 2015, Yihui Xie wrote: Your LyX example has two problems: Yihui, et al.: All fixed now. After adding the specific libraries the chuck calling xyplot() to produce the graphic caused an error when I tried to generate a dvips preview: LaTeX Error: File

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot() [RESOLVED]

2015-07-11 Thread Yihui Xie
I guess you didn't tell us you were compiling the document with dvips (BTW, I'm surprised that dvips is still alive today...), otherwise the solution would be simply to use the postscript device instead of the default pdf device (i.e. use the chunk option dev='postscript'). Hopefully you learned

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, David Winsemius wrote: #Generally one needs to complete a pdf() call with: dev.off() # And an empty file is the symptom os such a failure. David, I did leave that off the example file, but it make no difference. The attached is the compiled example.pdf Rich

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Yihui Xie
Your LyX example has two problems: 1) We don't have your .RData; 2) You didn't library(reshape) and library(lattice). Hence it is not a self-contained reproducible example. After fixing these two issues, I don't see why lattice graphics can be problematic with knitr. There is no need to print()

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread David Winsemius
On Jul 10, 2015, at 2:57 PM, Rich Shepard wrote: On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley, Only now. Had not thought of trying this before. pdf('carlin-1-descriptive.pdf') print(xyplot(value ~

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
I'd recommend starting with a simpler .Rmd or .Rnw file, rather than using it with lyx. The basic .Rmd file below works for me without any further adjustments: # Lattice test ```{r} library(lattice) xyplot(mpg ~ wt, data = mtcars) ``` Hadley On Fri, Jul 10, 2015 at 3:39 PM, Rich Shepard

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Roy Mendelssohn - NOAA Federal wrote: Don’t know for certain but might this help: It's very interesting, but does not appear to resolve the immediate need to write the R code in a knitr chunk for incorporation into the compiled LyX document. The gridGraphics package

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley On Friday, July 10, 2015, Rich Shepard rshep...@appl-ecosys.com wrote: Hadley's ggplot2 book is quite old and a new version is in the works, but not yet out. I've been using lattice graphics but the knitr

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried explicitly print()ing the lattice graphics in your knitr doc? Hadley, Only now. Had not thought of trying this before. pdf('carlin-1-descriptive.pdf') print(xyplot(value ~ sampdate | variable, data=carlin.1.melt, rm.na = T)) No

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Jeff Newmiller
I don't actually use lattice very much, but I have no difficulty setting up a lattice plot in a knitr/rmarkdown file, and can think of no reason why you might have concluded that knitr does not support lattice. Sorry, not going to translate your non-reproducible example... please go the extra

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Roy Mendelssohn - NOAA Federal
Don’t know for certain but might this help: http://journal.r-project.org/archive/2015-1/murrell.pdf From the latest issue of R Journal. Abstract The gridGraphics package provides a function, grid.echo(), that can be used to convert a plot drawn with the graphics package to a visually

[R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
Hadley's ggplot2 book is quite old and a new version is in the works, but not yet out. I've been using lattice graphics but the knitr package doesn't support lattice, only basic plots and ggplot2. My Web searches for Trellis plots in ggplot2 equivalent to those in lattice have not been

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Roy Mendelssohn - NOAA Federal wrote: Don’t know for certain but might this help: http://journal.r-project.org/archive/2015-1/murrell.pdf From the latest issue of R Journal. Roy, Thanks. I'll certainly read that article. Carpe weekend, Rich

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Hadley Wickham
You shouldn't be explicitly opening a device in a knitr document. I think maybe you should post a minimal document so we can figure out what's going wrong. Hadley On Friday, July 10, 2015, Rich Shepard rshep...@appl-ecosys.com wrote: On Fri, 10 Jul 2015, Hadley Wickham wrote: Have you tried

Re: [R] Trellis Plots: translating lattice xyplot() to ggplot()

2015-07-10 Thread Rich Shepard
On Fri, 10 Jul 2015, Hadley Wickham wrote: You shouldn't be explicitly opening a device in a knitr document. Hadley, Didn't think so. I think maybe you should post a minimal document so we can figure out what's going wrong. Agreed. Attached are the raw data (carlin.csv) and a