folder figure created when running knitr in Rnw file

rstudio
knitr

#1

I run knitr in a Rnw file. Get multiple graphic (pdf) files in a "figure" folder involuntarily. The folder appears to be useless and deleting it does not seem to hurt.

Is there a way to suppress (not creat) the folder? Thanks.


#2

I get the same thing, too. I think it's there to enable blogdown or bookdown to serve images in its public facing capacities, and if you don't have that purpose a `cron rm -rf' command should clear them out to avoid useless files.


#3

Thanks. Where do I enter that command? Thanks.


#4

From the terminal command line in its parent directory, but it could be rebuilt every time

```{r setup, include=FALSE}
###--- Update the knitr working directory (R works from the project folder, knitr works in the rmd folder)
dd <- getwd()
knitr::opts_knit$set(root.dir= paste(dd,'/../../')) 

###--- Set some knitr defaults for all of the code blocks below. 
knitr::opts_chunk$set(warning=FALSE
                      ,error=FALSE
                      ,message=FALSE
                      ,cache=F
                      ,eval=TRUE
                      ,results='asis'
                      ,echo=TRUE
                      ,fig.ext="png"
                      ,cache.path = paste0(dd,'/cache/')
                      ,fig.path = paste0(dd,'/figures/')
                      ) 

from pdbentley's answer to https://stackoverflow.com/questions/24585254/working-with-knitr-using-subdirectories

might work if you change the last line to

fig.path = '/dev/null' #Linux

On Windows 10 there seems to be a lot of confusion as to how to do the same thing in the registry, so I can't speculate.


#5

Oh my.. I am such a dunce... I've been putting these manually in every chunk! Thank you!