Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 针织机中图形的可显示自动编号_R_Knitr - Fatal编程技术网

R 针织机中图形的可显示自动编号

R 针织机中图形的可显示自动编号,r,knitr,R,Knitr,我正在用knitr编写一个HTML文档。我的设置是: --- fontsize: 12pt output: html_document: fig_height: 7 fig_width: 9 keep_md: yes smart: no --- ```{r global_options, include = FALSE} knitr::opts_chunk$set(comment = NA) ``` 我有一些代码块可以生成数字。每一个块都会产生一个图形。

我正在用knitr编写一个HTML文档。我的设置是:

---
fontsize: 12pt

output:
  html_document:
    fig_height: 7
    fig_width: 9
    keep_md: yes
    smart: no
---

```{r global_options, include = FALSE}
knitr::opts_chunk$set(comment = NA)
```
我有一些代码块可以生成数字。每一个块都会产生一个图形。我在标记这些块时理解到,当我编织文档时,块标签会成为图形的文件名。例如,我标记为“mtcar\u histogram”的块应该生成文件“mtcar\u histogram.png”

但是当我导航到包含我的文档的目录的“figure html”子目录时,我看到所有的数字都有一个自动的数字后缀。例如,我看到的是“mtcar\u histogram-1.png”,而不是“mtcar\u histogram.png”

当我检查时,我读到:

“注意,任何数量的绘图都可以记录在单个代码块中,此软件包不需要事先知道一个代码块中有多少个绘图--它可以自动计算出来,并将这些图像命名为fig.path-label-i,其中i从1递增”

但正如我前面所说的,我的块都不会产生多个图,所以编号对我来说是不必要的


是否有办法取消编号

迟交答案,但可能有用。摘自这里:

将此选项添加到安装程序块中

knitr::opts_chunk$set(
                  fig.process = function(x) {
                      x2 = sub('-\\d+([.][a-z]+)$', '\\1', x)
                      if (file.rename(x, x2)) x2 else x
                      }
                  )
这将删除后缀。小心使用