尽管render()成功创建了HTML文件

时间:2017-02-17 15:39:42

标签: r knitr r-markdown pandoc

我开始使用rmarkdownknitr。在RStudio提供的示例文档中,我可以成功使用render()生成一个在Chrome中可以正常查看的HTML文件。但是,当我单击knit按钮时,它会生成.markdown文件,然后返回以下错误而不呈现预览:

Error generating HTML preview for ~/path/to/file/report.rmarkdown system error 2 (The system cannot find the file specified)

我认为它在pandoc阶段被挂断了。 RStudio有可能在错误的地方寻找pandoc吗? Pandoc已经安装在C:\Program Files (x86)\Pandoc\pandoc.exe,但是RStudio在C:\Program Files\RStudio\bin\pandoc\pandoc.exe安装了自己的实例,所以它可能在一个错误的位置和/或一个与另一个混淆的设置?

非常感谢任何帮助。谢谢!

以防万一,这里是我开始的RMarkdown模板:

---
title: "Monthly Report"
author: "Kris Shaffer"
date: "February 17, 2017"
output: html_document
---

```{r setup, include=FALSE}
library(knitr)
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

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 cars}
summary(cars)
```

## Including Plots

You can also embed plots, for example:

```{r pressure, echo=FALSE}
plot(pressure)
```

Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.

R版本3.3.2
RStudio 1.0.136
rmarkdown 1.3
knitr 1.15.1
pandoc 1.17.2(两个装置)

1 个答案:

答案 0 :(得分:0)

事实证明它就像文件扩展名一样简单。我将文件名从report.rmarkdown更改为report.Rmd。针织工作现在很好。