我似乎无法让 knitr 与 tikzdevice 一起工作。一个简单的例子:
\documentclass{article}
\begin{document}
<<test, dev='tikz'>>=
library(knitr)
library(tikzDevice)
library(ggplot2)
plot(1)
@
\end{document}
生成:
Quitting from lines 4-5 (testets.Rnw)
Error in system(latexCmd, intern = T, ignore.stderr = T) :
'C:\Program' not found
Calls: knit ... print.recordedplot -> replayPlot -> <Anonymous> -> getMetricsFromLatex
在我看来,路径包含空格显然存在问题 - 我的 LaTeX 安装在“C:\Program Files\”下,但我不知道如何修复它,除非重新安装 Latex。值得一提的是,只要我不调用 tikzDevice,knitr 就可以正常工作,并且 MikTeX + tikz 在 knitr 之外也可以正常工作。
sessionInfo() 产生:
R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_1.0.0 tikzDevice_0.8.1 knitr_1.8
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 digest_0.6.8 evaluate_0.5.5 filehash_2.2-2 formatR_1.0 grid_3.1.2 gtable_0.1.2
[8] labeling_0.3 MASS_7.3-35 munsell_0.4.2 plyr_1.8.1 proto_0.3-10 Rcpp_0.11.3 reshape2_1.4.1
[15] scales_0.2.4 stringr_0.6.2 tools_3.1.2