无法将“有效的R编程”的Bookdown源代码编译为PDF

时间:2018-08-05 15:07:43

标签: r latex markdown

我正在尝试在Windows 7计算机上使用RStudio编译Efficient R Programming的PDF版本。使用说明here,我可以编译HTML版本,但是PDF版本的代码失败。运行下面的代码(乍看起来似乎可以正常运行)后,我收到以下警告消息:

## For pdf
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_book())

output file: _main.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS _main.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output _main.tex --table-of-contents --toc-depth 2 --template "C:\R\R-3.4.4\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --number-sections --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes" --variable tables=yes --standalone --filter pandoc-citeproc 
Error: Failed to compile _main.tex.
In addition: Warning messages:
1: In file.remove("voc_voyages.xlsx") :
  cannot remove file 'voc_voyages.xlsx', reason 'No such file or directory'
2: In connection_release(conn@ptr) :
  There are 1 result in use. The connection will be released when they are closed
3: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  no date field in DESCRIPTION file of package 'benchmarkme'
4: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  could not determine year for 'benchmarkme' from package DESCRIPTION file
5: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  no date field in DESCRIPTION file of package 'bookdown'
6: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  could not determine year for 'bookdown' from package DESCRIPTION file
7: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  no date field in DESCRIPTION file of package 'efficient'
8: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  could not determine year for 'efficient' from package DESCRIPTION file
9: running command '"pdflatex" -halt-on-error -interaction=batchmode "_main.tex"' had status 127 
Please delete _main.Rmd after you finish debugging the error.

我找到了this discussion of MikTeX vs tinytex。然后,我安装了tinytex,现在收到此(略有不同)错误:

## For pdf
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_book())

    label: unnamed-chunk-235

  ordinary text without R code


label: unnamed-chunk-236

  ordinary text without R code


label: unnamed-chunk-237 (with options) 
List of 1
 $ message: logi FALSE


Attaching package: 'Matrix'

The following object is masked from 'package:tidyr':

    expand


  ordinary text without R code


label: unnamed-chunk-238
  |...............................................                  |  73%
  ordinary text without R code


label: unnamed-chunk-239 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-240 (with options) 
List of 2
 $ results: chr "hide"
 $ indent : chr "    "


  ordinary text without R code

  |................................................                 |  73%
label: 7-4 (with options) 
List of 3
 $ echo     : logi FALSE
 $ out.width: chr "100%"
 $ fig.cap  : chr "Code profiling of the optimised code."


  ordinary text without R code


label: unnamed-chunk-241 (with options) 
List of 2
 $ eval: logi FALSE
 $ echo: logi FALSE


  ordinary text without R code

  |................................................                 |  74%
label: unnamed-chunk-242 (with options) 
List of 1
 $ echo: language 1:2


  ordinary text without R code


label: unnamed-chunk-243 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-244 (with options) 
List of 2
 $ eval: logi FALSE
 $ tidy: logi FALSE


  ordinary text without R code


label: unnamed-chunk-245 (with options) 
List of 2
 $ eval: logi FALSE
 $ echo: language c(1, 3)


  ordinary text without R code

  |................................................                 |  75%
label: unnamed-chunk-246 (with options) 
List of 2
 $ eval: logi FALSE
 $ echo: language 2:3

  |.................................................                |  75%
  ordinary text without R code


label: unnamed-chunk-247 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-248 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-249

  ordinary text without R code

  |.................................................                |  76%
label: unnamed-chunk-250 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-251 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-252 (with options) 
List of 1
 $ results: chr "hide"

  |..................................................               |  76%
  ordinary text without R code


label: 7-5 (with options) 
List of 7
 $ echo      : logi FALSE
 $ fig.cap   : chr "Downloads per day from the RStudio CRAN mirror of packages that provide R interfaces to other languages."
 $ warning   : logi FALSE
 $ fig.width : num 6
 $ fig.height: num 4
 $ out.width : chr "70%"
 $ fig.align : chr "center"


   inline R code fragments

  |..................................................               |  77%
label: test_cpp (with options) 
List of 2
 $ eval   : logi FALSE
 $ results: chr "hide"


  ordinary text without R code


label: unnamed-chunk-253

  ordinary text without R code


label: unnamed-chunk-254 (with options) 
List of 3
 $ eval  : logi FALSE
 $ tidy  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code


label: unnamed-chunk-255 (with options) 
List of 1
 $ tidy: logi FALSE


  ordinary text without R code

  |..................................................               |  78%
label: unnamed-chunk-256

  ordinary text without R code

  |...................................................              |  78%
label: unnamed-chunk-257

  ordinary text without R code


label: unnamed-chunk-258 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: cpptypes (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code

  |...................................................              |  79%
label: unnamed-chunk-259 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code


label: unnamed-chunk-260 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code


label: unnamed-chunk-261 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code

  |....................................................             |  79%
label: unnamed-chunk-262 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code

  |....................................................             |  80%
label: unnamed-chunk-263 (with options) 
List of 1
 $ engine: chr "Rcpp"

Building shared library for Rcpp code chunk...

  ordinary text without R code


label: unnamed-chunk-264

  ordinary text without R code


label: unnamed-chunk-265 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code


label: unnamed-chunk-266

  ordinary text without R code


label: unnamed-chunk-267 (with options) 
List of 3
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"
 $ indent: chr "    "

  |....................................................             |  81%
  ordinary text without R code


label: unnamed-chunk-268 (with options) 
List of 3
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"
 $ indent: chr "    "

  |.....................................................            |  81%
  ordinary text without R code


label: unnamed-chunk-269

  ordinary text without R code


label: unnamed-chunk-270 (with options) 
List of 3
 $ cache: logi TRUE
 $ echo : language -1
 $ eval : logi FALSE


  ordinary text without R code


label: 7-6 (with options) 
List of 7
 $ fig.width : num 6
 $ fig.height: num 4
 $ echo      : num 2
 $ fig.cap   : chr "Comparison of mean functions."
 $ cache     : logi TRUE
 $ fig.pos   : chr "t"
 $ out.width : chr "70%"

  |.....................................................            |  82%
  ordinary text without R code


label: unnamed-chunk-271 (with options) 
List of 3
 $ eval  : logi FALSE
 $ tidy  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code


label: unnamed-chunk-272 (with options) 
List of 3
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"
 $ indent: chr "    "


  ordinary text without R code


label: unnamed-chunk-273
  |......................................................           |  82%
  ordinary text without R code


label: unnamed-chunk-274 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"

  |......................................................           |  83%
  ordinary text without R code


label: unnamed-chunk-275 (with options) 
List of 2
 $ eval  : logi FALSE
 $ engine: chr "Rcpp"


  ordinary text without R code


label: unnamed-chunk-276 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-277 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-278
  |......................................................           |  84%
  ordinary text without R code


label: ascii (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code

  |.......................................................          |  84%
label: unnamed-chunk-279 (with options) 
List of 1
 $ echo: num 2


  ordinary text without R code


label: unnamed-chunk-280

  ordinary text without R code


label: unnamed-chunk-281
  |.......................................................          |  85%
  ordinary text without R code


label: unnamed-chunk-282 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-283 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-284 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code

  |........................................................         |  85%
label: 8-1 (with options) 
List of 3
 $ fig.cap  : chr "Three DIMM slots on a computer motherboard used for increasing the amount of available RAM. Credit: Wikimedia.org"
 $ echo     : logi FALSE
 $ out.width: chr "100%"

  |........................................................         |  86%
  ordinary text without R code


label: unnamed-chunk-285

  ordinary text without R code


label: unnamed-chunk-286

  ordinary text without R code


label: unnamed-chunk-287 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code


label: 8-2 (with options) 
List of 2
 $ fig.cap: chr "A standard 2.5\" hard drive, found in most laptops. Credit: https://en.wikipedia.org/wiki/Hard\\_disk\\_drive"
 $ echo   : logi FALSE

  |........................................................         |  87%
  ordinary text without R code


label: unnamed-chunk-288 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-289 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"

  |.........................................................        |  87%
  ordinary text without R code


label: unnamed-chunk-290 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code


label: 8-3 (with options) 
List of 5
 $ echo      : logi FALSE
 $ fig.width : num 6
 $ fig.height: num 4
 $ fig.cap   : chr "CPU clock speed. The data for this figure was collected from web-forum and wikipedia. It is intended to indicat"| __truncated__
 $ out.width : chr "70%"


  ordinary text without R code

  |.........................................................        |  88%
label: 8-4 (with options) 
List of 6
 $ echo      : logi FALSE
 $ fig.width : num 6
 $ fig.height: num 4
 $ fig.cap   : chr "CPU benchmarks from the R package, **benchmarkme**. Each point represents an individual CPU result."
 $ fig.keep  : chr "last"
 $ out.width : chr "70%"


  ordinary text without R code


label: unnamed-chunk-291 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-292 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-293 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE

  |..........................................................       |  88%
  ordinary text without R code

  |..........................................................       |  89%
label: unnamed-chunk-294 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-295 (with options) 
List of 2
 $ echo   : logi FALSE
 $ message: logi FALSE


  ordinary text without R code


label: unnamed-chunk-296 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-297

  ordinary text without R code

  |..........................................................       |  90%
label: unnamed-chunk-298

  ordinary text without R code


label: unnamed-chunk-299 (with options) 
List of 2
 $ engine: chr "bash"
 $ eval  : logi FALSE


  ordinary text without R code

  |...........................................................      |  90%
label: unnamed-chunk-300 (with options) 
List of 1
 $ messages: logi FALSE


  ordinary text without R code


label: unnamed-chunk-301

  ordinary text without R code

  |...........................................................      |  91%
label: unnamed-chunk-302

  ordinary text without R code


label: unnamed-chunk-303 (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-304 (with options) 
List of 2
 $ results: chr "hide"
 $ message: logi FALSE


Attaching package: 'lubridate'

The following objects are masked from 'package:data.table':

    hour, isoweek, mday, minute, month, quarter, second, wday,
    week, yday, year

The following object is masked from 'package:base':

    date


  ordinary text without R code


label: unnamed-chunk-305 (with options) 
List of 2
 $ eval   : logi FALSE
 $ results: chr "hide"


  ordinary text without R code

  |...........................................................      |  92%
label: unnamed-chunk-306 (with options) 
List of 2
 $ echo   : language 2:5
 $ results: chr "hide"

  |............................................................     |  92%
  ordinary text without R code


label: unnamed-chunk-307 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-308 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-309 (with options) 
List of 1
 $ results: chr "hide"


  ordinary text without R code

  |............................................................     |  93%
label: 9-1 (with options) 
List of 3
 $ fig.cap  : chr "The Git tab in RStudio"
 $ echo     : logi FALSE
 $ out.width: chr "70%"


  ordinary text without R code


label: 9-2 (with options) 
List of 3
 $ fig.cap  : chr "The Git history navigation interface"
 $ echo     : logi FALSE
 $ out.width: chr "100%"


  ordinary text without R code


label: unnamed-chunk-310 (with options) 
List of 1
 $ eval: logi FALSE

  |.............................................................    |  93%
  ordinary text without R code


label: note-text (with options) 
List of 2
 $ type  : chr "rmdwarning"
 $ engine: chr "block"


  ordinary text without R code


label: unnamed-chunk-311 (with options) 
List of 2
 $ engine: chr "bash"
 $ eval  : logi FALSE

  |.............................................................    |  94%
  ordinary text without R code


label: unnamed-chunk-312 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-313 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-314 (with options) 
List of 1
 $ echo: logi FALSE


  ordinary text without R code


label: unnamed-chunk-315
  |.............................................................    |  95%
  ordinary text without R code

  |..............................................................   |  95%
label: unnamed-chunk-316 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-317 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-318 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-319
  |..............................................................   |  96%
  ordinary text without R code


label: unnamed-chunk-320 (with options) 
List of 3
 $ echo     : logi FALSE
 $ fig.cap  : chr "Package name autocompletion in action in RStudio for packages beginning with 'geo'."
 $ out.width: chr "100%"


  ordinary text without R code


label: unnamed-chunk-321 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"


  ordinary text without R code

  |...............................................................  |  96%
label: unnamed-chunk-322 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-323 (with options) 
List of 1
 $ eval: logi FALSE

  |...............................................................  |  97%
  ordinary text without R code


label: unnamed-chunk-324 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-325

  ordinary text without R code


label: unnamed-chunk-326 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-327 (with options) 
List of 2
 $ type  : chr "rmdnote"
 $ engine: chr "block"

  |...............................................................  |  98%
  ordinary text without R code


label: unnamed-chunk-328 (with options) 
List of 2
 $ type  : chr "rmdtip"
 $ engine: chr "block"

  |................................................................ |  98%
  ordinary text without R code


label: unnamed-chunk-329 (with options) 
List of 1
 $ eval: logi FALSE


  ordinary text without R code


label: unnamed-chunk-330 (with options) 
List of 1
 $ echo: language -3


  ordinary text without R code


label: unnamed-chunk-331 (with options) 
List of 1
 $ results: chr "hide"

  |................................................................ |  99%
  ordinary text without R code


label: unnamed-chunk-332 (with options) 
List of 2
 $ include: logi FALSE
 $ cache  : logi FALSE


  ordinary text without R code


label: unnamed-chunk-333 (with options) 
List of 2
 $ eval  : logi FALSE
 $ indent: chr "    "


  ordinary text without R code


label: unnamed-chunk-334 (with options) 
List of 1
 $ eval: logi FALSE

  |.................................................................|  99%
  ordinary text without R code


label: is_travis (with options) 
List of 1
 $ echo: logi FALSE

  |.................................................................| 100%
  ordinary text without R code


label: unnamed-chunk-335 (with options) 
List of 4
 $ echo   : logi FALSE
 $ warning: logi FALSE
 $ message: logi FALSE
 $ eval   : language, mode "(": (!is_travis)

tweaking fortunes

  ordinary text without R code


label: unnamed-chunk-336 (with options) 
List of 3
 $ echo   : logi FALSE
 $ message: logi FALSE
 $ warning: logi FALSE


  ordinary text without R code


output file: _main.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS _main.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output _main.tex --table-of-contents --toc-depth 2 --template "C:\R\R-3.4.4\library\rmarkdown\rmd\latex\default-1.17.0.2.tex" --number-sections --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in" --variable "compact-title:yes" --variable tables=yes --standalone --filter pandoc-citeproc 

Output created: _book/_main.pdf
Error in tools::file_path_as_absolute(output_file) : 
  file '_book/_main.pdf' does not exist
In addition: Warning messages:
1: In file.remove("voc_voyages.xlsx") :
  cannot remove file 'voc_voyages.xlsx', reason 'No such file or directory'
2: In connection_release(conn@ptr) :
  There are 1 result in use. The connection will be released when they are closed
3: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  no date field in DESCRIPTION file of package 'benchmarkme'
4: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  could not determine year for 'benchmarkme' from package DESCRIPTION file
5: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  no date field in DESCRIPTION file of package 'bookdown'
6: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  could not determine year for 'bookdown' from package DESCRIPTION file
7: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  no date field in DESCRIPTION file of package 'efficient'
8: In citation(pkg, auto = if (pkg == "base") NULL else TRUE) :
  could not determine year for 'efficient' from package DESCRIPTION file
9: running command '"pdflatex" -halt-on-error -interaction=batchmode "_main.tex"' had status 1 
10: In readLines(logfile) : incomplete final line found on '_main.log'
Please delete _main.Rmd after you finish debugging the error.

基于下面@jaySf的评论,我运行了这段代码,但仍然遇到相同的错误:

remove.packages("rmarkdown")
install.packages("devtools")
library(devtools)
install_version("rmarkdown", version = "1.8")

## For pdf
bookdown::render_book("index.Rmd", output_format = bookdown::pdf_book())

任何建议将不胜感激。谢谢。

0 个答案:

没有答案