Rich Shepard
2015-Jul-11 00:18 UTC
[R] Trellis Plots: translating lattice xyplot() to ggplot()
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: example.pdf Type: application/pdf Size: 63741 bytes Desc: URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150710/0f2c8fa1/attachment.pdf>
Yihui Xie
2015-Jul-11 01:46 UTC
[R] Trellis Plots: translating lattice xyplot() to ggplot()
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() the plot, and no need to pdf(), either. See the attached PDF I generated. Regards, Yihui -- Yihui Xie <xieyihui at gmail.com> Web: http://yihui.name On Fri, Jul 10, 2015 at 7:18 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:> 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 > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.-------------- next part -------------- A non-text attachment was scrubbed... Name: example.pdf Type: application/pdf Size: 57487 bytes Desc: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20150710/ca3f32e2/attachment.pdf>
Rich Shepard
2015-Jul-11 13:06 UTC
[R] Trellis Plots: translating lattice xyplot() to ggplot()
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 file. Here, lattice and reshape2 are loaded when R is invoked. However, explicitly loading them in the embedded code will be done.> After fixing these two issues, I don't see why lattice graphics can be > problematic with knitr. There is no need to print() the plot, and no > need to pdf(), either. See the attached PDF I generated.I'll see if requireing those two libraries in the document resolves the issue. Initially, I did not specify pdf() and added the explicit print() based on that suggestion in this thread. Will test later today. Thanks very much, Rich
Rich Shepard
2015-Jul-11 14:03 UTC
[R] Trellis Plots: translating lattice xyplot() to ggplot() [RESOLVED]
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 'figure/unnamed-chunk-7-1' not found. I could not locate the file with any of these extensions: .eps,.ps,.eps.gz,.ps.gz,.eps.Z Which is what sent me down the path of specifying pdf() and dev.off(). However, compiling with pdflatex produces the graphic in the document. All part of being brand new to using knitr. Thank you all very much, Rich