重用包括使用knitr .Rmd进行绘制的块 [英] reusing chunks that include plotting with knitr .Rmd
本文介绍了重用包括使用knitr .Rmd进行绘制的块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当重复使用包含绘图的块时,未正确引用这些图,即,尽管两个块应该是不同的,但它们对于两个块都是相同的.我该怎么办?
## Test
```{r}
col <- "black"
```
```{r chunk1}
plot(0, col=col)
```
```{r}
col <- "red"
```
```{r chunk1}
```
解决方案
您应该使用其他标签,例如
```{r chunk2, ref.label='chunk1'}
```
请参见 http://yihui.name/knitr/demo/reference/ >
When a chunk that includes plotting is reused the plots are not referenced properly, i.e. they are identical for both chunks though they are supposed to be different. What can I do about it?
## Test
```{r}
col <- "black"
```
```{r chunk1}
plot(0, col=col)
```
```{r}
col <- "red"
```
```{r chunk1}
```
解决方案
You should use a different label like
```{r chunk2, ref.label='chunk1'}
```
See http://yihui.name/knitr/demo/reference/
这篇关于重用包括使用knitr .Rmd进行绘制的块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文