[R] Knitr/Lattice/Lyx [was: Trellis Plots: translating lattice xyplot() to ggplot()]

Yihui Xie xie at yihui.name
Sun Jul 12 02:43:44 CEST 2015


Perhaps it is not obvious to you, but it is fairly obvious to me that
the R code in this code chunk is incomplete:

<<>>=
xyplot(value ~ sampdate | variable, data=carlin.2.melt, rm.na = T,
ylab = 'Measured Value', xlab = 'Date'
@

There is a ')' missing in the end. When you see errors from parse(),
that often means the code is not syntactically correct.

Regards,
Yihui
--
Yihui Xie <xieyihui at gmail.com>
Web: http://yihui.name


On Sat, Jul 11, 2015 at 7:07 PM, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> On Sat, 11 Jul 2015, Yihui Xie wrote:
>
>> I guess you didn't tell us you were compiling the document with dvips
>
>
>   That's how I preview lyx docs for the past decade-and-a-half or so. The
> final .pdf is generated with pdflatex.
>
>   There is now an issue when a second figure is added to the document: it
> won't compile.
>
>   Attached are the .RData file from the cwd, the test.lyx file (lyx-2.1.3),
> and the two test files from /tmp/.../lyx_tmpbuf3/.
>
>   Here are the lyx messages when I tried compiling the document with
> pdflatex:
>
> 16:51:11.255: Exporting ...
> 16:51:11.259: (buffer-export pdf2)
> 16:51:11.278: Rscript --verbose --no-save --no-restore
> "/usr/share/lyx/scripts/lyxknitr.R"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.Rnw"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.tex" ISO-8859-15
> "/home/rshepard/documents/white-papers/water-chem-anal/"
> 16:51:11.281: running
> 16:51:11.286:   '/usr/lib/R/bin/R --slave --no-restore --no-save
> --no-restore --file=/usr/share/lyx/scripts/lyxknitr.R --args
> -- /tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/test.Rnw
> -- / /tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpb
> 16:51:11.288: uf3/test.tex ISO-8859-15
> /home/rshepard/documents/white-papers/water-chem-anal/'
> 16:51:11.292: 16:51:11.697: Loading required package: methods
> 16:51:11.709: Loading required package: survival
> 16:51:11.712: Loading required package: graphics
> 16:51:11.721: Loading required package: stats
> 16:51:11.921: 16:51:11.923: Attaching package: ‘NADA’
> 16:51:11.925: 16:51:11.927: The following object is masked from
> ‘package:stats’:
> 16:51:11.929: 16:51:11.932:     cor
> 16:51:11.933: 16:51:11.969: 16:51:11.970: Attaching package: ‘zoo’
> 16:51:11.972: 16:51:11.975: The following objects are masked from
> ‘package:base’:
> 16:51:11.976: 16:51:11.979:     as.Date, as.Date.numeric
> 16:51:11.981: 16:51:12.091: 16:51:12.092: 16:51:12.094: processing file:
> /tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/test.Rnw
> 16:51:12.112:
>   |
>   |                                                                 |   0%
>   | 16:51:12.113:
>   |....                                                             |   6%
> 16:51:12.116:   ordinary text without R code
> 16:51:12.118: 16:51:12.120:
>   |
>   |........                                                         |  12%
> 16:51:12.123: label: unnamed-chunk-1 (with options) 16:51:12.126: List of 1
> 16:51:12.128:  $ echo: logi FALSE
> 16:51:12.130: 16:51:12.204:
>   |
>   |...........                                                      |  18%
> 16:51:12.205:   ordinary text without R code
> 16:51:12.207: 16:51:12.210:
>   |
>   |...............                                                  |  24%
> 16:51:12.213: label: unnamed-chunk-2
> 16:51:12.239:
>   |
>   |...................                                              |  29%
> 16:51:12.240:   ordinary text without R code
> 16:51:12.242: 16:51:12.244:
>   |
>   |.......................                                          |  35%
> 16:51:12.247: label: unnamed-chunk-3
> 16:51:12.293:
>   |
>   |...........................                                      |  41%
> 16:51:12.295:   ordinary text without R code
> 16:51:12.297: 16:51:12.299:
>   |
>   |...............................                                  |  47%
> 16:51:12.302: label: unnamed-chunk-4
> 16:51:12.344:
>   |
>   |..................................                               |  53%
> 16:51:12.346:   ordinary text without R code
> 16:51:12.348: 16:51:12.350:
>   |
>   |......................................                           |  59%
> 16:51:12.353: label: unnamed-chunk-5
> 16:51:12.432:
>   |
>   |..........................................                       |  65%
> 16:51:12.434:   ordinary text without R code
> 16:51:12.436: 16:51:12.438:
>   |
>   |..............................................                   |  71%
> 16:51:12.441: label: unnamed-chunk-6
> 16:51:12.484:
>   |
>   |..................................................               |  76%
> 16:51:12.486:   ordinary text without R code
> 16:51:12.488: 16:51:12.490:
>   |
>   |......................................................           |  82%
> 16:51:12.493: label: unnamed-chunk-7
> 16:51:12.837:
>   |
>   |.........................................................        |  88%
> 16:51:12.839:   ordinary text without R code
> 16:51:12.841: 16:51:12.843:
>   |
>   |.............................................................    |  94%
> 16:51:12.846: label: unnamed-chunk-8
> 16:51:12.849: Quitting from lines 101-102
> (/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/test.Rnw) 16:51:12.851: Error in
> parse(text = x, srcfile = src) : 16:51:12.853:   <text>:2:0: unexpected end
> of input
> 16:51:12.855: 1: xyplot(value ~ sampdate | variable, data=carlin.2.melt,
> rm.na = T, ylab = 'Measured Value', xlab = 'Date'
> 16:51:12.857:    ^
> 16:51:12.859: Calls: knit ... <Anonymous> -> parse_all ->
> parse_all.character -> parse
> 16:51:12.861: 16:51:12.862: Execution halted
> Systemcall.cpp (292): Systemcall: 'Rscript --verbose --no-save --no-restore
> "/usr/share/lyx/scripts/lyxknitr.R"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.Rnw"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.tex" ISO-8859-15
> "/home/rshepard/documents/white-papers/water-chem-anal/"' finished with exit
> code 1
> Error: Cannot convert file
> ----------------------------------------
> An error occurred while running:
> Rscript --verbose --no-save --no-restore "/usr/share/lyx/scripts/lyxknitr.R"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.Rnw"
> "/tmp/lyx_tmpdir.rGQZdOZ30938/lyx_tmpbuf3/""test.tex" ISO-8859-15
> "/home/rshepard/documents/white-papers/water-chem-anal/"
> 16:51:16.136: Error while exporting format: PDF (pdflatex)
>
>   There is no log file in the tempbuf. Note the references to
> unnamed-chunks. Each chunk is labeled with a number when opened in lyx; the
> two figures each have a distinct label. I don't see the specific error
> generated by adding a second figure to the document. If there are more files
> needed to reproduce this situation, let me know and I'll provide it.
>
> Rich



More information about the R-help mailing list