Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R- Invalid filename error when plotting in Rmarkdown

I just installed Rstudio 1.0.44 on a company windows 64-bit PC. 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. The plots can be displayed if I execute the codes in console.

My R version is:

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.

like image 373
convertibile IkE Avatar asked Oct 18 '22 10:10

convertibile IkE


1 Answers

I had this problem when using a % in the chunk name. For example

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

```

Worked fine once I removed the %.

like image 142
PupHendo Avatar answered Nov 03 '22 06:11

PupHendo