简体   繁体   English

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

[英]R- Invalid filename error when plotting in Rmarkdown

I just installed Rstudio 1.0.44 on a company windows 64-bit PC.我刚刚在公司的 Windows 64 位 PC 上安装了 Rstudio 1.0.44。 When I tried to make any plot, I got this error:当我尝试制作任何情节时,出现此错误:

Error in (function (filename = "Rplot%03d.png", width = 480, height = 480,  : invalid 'filename'

Now the Traceback showed me this information:现在回溯向我展示了这个信息:

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)

I am using Rstudio 1.0.44 and I was using R Notebook.我使用的是 Rstudio 1.0.44,我使用的是 R Notebook。 The plots can be displayed if I execute the codes in console.如果我在控制台中执行代码,则可以显示这些图。

My R version is:我的 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       

There is another similar question on Stack overflow but there is not a workable answer.关于堆栈溢出还有另一个类似的问题,但没有可行的答案。 Any help will be highly appreciated!任何帮助将不胜感激!

Edit:编辑:

I used a % in the name.我在名称中使用了 %。 The issue disappeared after removing the symbol.删除符号后问题消失。

I had this problem when using a % in the chunk name.在块名称中使用 % 时遇到了这个问题。 For example例如

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

```

Worked fine once I removed the %.一旦我删除了 %.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM