我想通过RGui的RMarkdown生成PDF。 我可以通过RStudio编织文件,但每次都通过RGui失败。
这是包含渲染命令的“essai.r”文件。
library(rmarkdown)
library(knitr)
Sys.setenv(RSTUDIO_PANDOC="C:/Program Files (x86)/Pandoc")
rmarkdown::render("essai.Rmd", output_format = "pdf_document", clean = FALSE)
这是“essai.rmd”
---
title: "test"
output: pdf_document
---
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r}
summary(cars)
```
You can also embed plots, for example:
```{r, echo=FALSE}
plot(cars)
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.
这是我的配置:
> sessionInfo()
R version 3.3.0 (2016-05-03)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows Server 2012 R2 x64 (build 9600)
locale:
[1] LC_COLLATE=French_Switzerland.1252 LC_CTYPE=French_Switzerland.1252 LC_MONETARY=French_Switzerland.1252
[4] LC_NUMERIC=C LC_TIME=French_Switzerland.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.12.3 rmarkdown_0.9.5
loaded via a namespace (and not attached):
[1] magrittr_1.5 formatR_1.4 tools_3.3.0 htmltools_0.3.6 yaml_2.1.13 Rcpp_0.11.2
[7] stringi_1.0-1 stringr_1.0.0 digest_0.6.13 evaluate_0.8
这是每次出现的错误:
> source("essai.r")
"C:/Program Files (x86)/Pandoc/pandoc" +RTS -K512m -RTS essai.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output essai.pdf --template "C:\PROGRA~1\R\R-33~1.0\library\RMARKD~1\rmd\latex\DEFAUL~2.TEX" --highlight-style tango --latex-engine pdflatex --variable graphics=yes --variable "geometry:margin=1in"
pandoc.exe: Cannot decode byte '\xbd': Data.Text.Internal.Encoding.Fusion.streamUtf8: Invalid UTF-8 stream
Erreur : pandoc document conversion failed with error 1
我确保两个文件都保存为UTF-8。而且我也试图改变我的系统区域设置。
我错过了什么?
此致