我从 Roger Peng 的教程中复制了一个降价文件。我能够编织到 html 和 Word,但在编织到 pdf 时遇到了问题。test.Rmd 代码:
My First Knitr Document
===============================
This is some text (i.e. a text chunk).
here is a code chunk
```{r}
set.seed(1)
x <- rnorm(100)
mean(x)
```
点击'knit to pdf'后,错误:
Output created: test.pdf
Error in tools::file_path_as_absolute(output_file) :
file 'test.pdf' does not exist
Calls: <Anonymous> -> <Anonymous>
In addition: Warning messages:
1: running command '"pdflatex" -halt-on-error -interaction=batchmode
"test.tex"' had status 1
2: In readLines(logfile) : incomplete final line found on 'test.log'
Execution halted
当我在 cmd (windows) 中运行 'latexmk -version' 时,我得到:
latexmk: warning: running with administrator privileges
latexmk: The script engine could not be found
latexmk: Data: scriptEngine="perl.exe"
我的会话信息:
R version 3.4.4 (2018-03-15)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tinytex_0.4 sp_1.2-7
loaded via a namespace (and not attached):
[1] Rcpp_0.12.16 lattice_0.20-35 withr_2.1.2 digest_0.6.15
rprojroot_1.3-2 grid_3.4.4
[7] R6_2.2.2 backports_1.1.2 magrittr_1.5 evaluate_0.10.1
httr_1.3.1 stringi_1.1.7
[13] rmarkdown_1.9 devtools_1.13.5 tools_3.4.4 stringr_1.3.0
yaml_2.1.18 compiler_3.4.4
[19] memoise_1.1.0 htmltools_0.3.6 knitr_1.20
我的 MikTex 版本:basic-miktex-2.9.6。
更新,更准确地说,相同的代码在 mac 上运行良好(虽然 R 版本 3.4.0)。
更多信息:我在 E 盘上安装了 RStudio,而在 C 盘上安装了 MikTex。
另外,我可以使用 R Sweave 编译 pdf。
如果有人可以提供帮助,我将不胜感激。