Rmarkdown:Duplicate chunk label ‘plot‘, which has been used for the chunk:

Rmarkdown:Duplicate chunk label ‘plot’, which has been used for the chunk:

Error in parse_block(g[-1], g[1], params.src, markdown_mode) : Duplicate chunk label ‘plot’, which has been used for the chunk:
原因:我有两个绘图代码块,但没有命名,系统认为两个代码块是同名的,所以报错。

```{r plot}
plot(x,sqrt(x^(-m))*fit1$residuals,main="残差图")
```{r plot}
plot(x,sqrt(x^(-m))*fit2$residuals,main="残差图")
解决办法为:在{r plot}里加上命名,如下:
```{r plot1 plot}
plot(x,sqrt(x^(-m))*fit2$residuals,main="残差图")
```{r plot2 plot}
plot(x,sqrt(x^(-m))*fit1$residuals,main="残差图")

你可能感兴趣的:(r语言,markdown)