R- 在 Rmarkdown 中绘图时文件名无效错误

con*_*IkE 5 plot r rstudio r-markdown rnotebook

我刚刚在公司的 Windows 64 位 PC 上安装了 Rstudio 1.0.44。当我尝试制作任何情节时,出现此错误:

Error in (function (filename = "Rplot%03d.png", width = 480, height = 480,  : invalid 'filename'
Run Code Online (Sandbox Code Playgroud)

现在回溯向我展示了这个信息:

8. stop("invalid 'filename'")
7. (function (filename = "Rplot%03d.png", width = 480, height = 480, units = "px", pointsize = 12, 
 bg = "white", res = NA, family = "sans", restoreConsole = TRUE,
 type = c("windows", "cairo", "cairo-png"), antialias = c("default", "none", "cleartype", "gray", "subpixel")) ...
6. do.call(what = png, args = args)
5. .rs.createNotebookGraphicsDevice(filename, height, width, units, pixelRatio, extraArgs)
4. (function () { .rs.createNotebookGraphicsDevice(filename, height, width, units, pixelRatio, extraArgs) ...
3. grid.newpage()
2. print.ggplot(x)
1. function (x, ...) UseMethod("print")(x)
Run Code Online (Sandbox Code Playgroud)

我使用的是 Rstudio 1.0.44,我使用的是 R Notebook。如果我在控制台中执行代码,则可以显示这些图。

我的 R 版本是:

platform       x86_64-w64-mingw32          
arch           x86_64                      
os             mingw32                     
system         x86_64, mingw32             
status                                     
major          3                           
minor          3.2                         
year           2016                        
month          10                          
day            31                          
svn rev        71607                       
language       R                           
version.string R version 3.3.2 (2016-10-31)
nickname       Sincere Pumpkin Patch       
Run Code Online (Sandbox Code Playgroud)

关于堆栈溢出还有另一个类似的问题,但没有可行的答案。任何帮助将不胜感激!

编辑:

我在名称中使用了 %。删除符号后问题消失。

小智 4

我在块名称中使用 % 时遇到了这个问题。例如

``` {r next%, echo=TRUE}

```
Run Code Online (Sandbox Code Playgroud)

当我删除%后,工作正常。