RMarkown PDF Document - Removes other files??

Hi,

I am knitting a document, and I am knitting it with github_document (to post to github) and also with the normal pdf_document. However, when i do this, knitting it as a pdf deletes all the files in the figure-gfm folder, messing up my github document. Has anyone dealt with this? If so, is there a way to fix this?

Thanks,

Alan

By default, format html_document use self_contained=TRUE, and with this option, intermediates files are cleaned when rendering with default args.

However, rmarkdown::render has an option clean=TRUE by default that you could set to FALSE so that the intermediates directory is not clean as needed by the html file.

---
title: "R Notebook"
output: 
  github_document: default
  html_document: 
      self_contained: true
---

This is a test file

```{r cars-plot, fig.cap = "plot of cars"}
plot(cars)
```

```{r mean-speed}
mean_speed <- mean(cars$speed)
```

rendered using rmarkdown::render("test.Rmd", clean = FALSE) will leave the files.
You can also use self_contained: FALSE and files won't be cleaned.

Now, it seems odd the the whole intermediate dir is cleaned while there is still some files inside (gfm directory). I will look into the source code to see if this is an issue and can be improve.

1 Like

Ok. so there is indeed a line in the code that clean the intermediate files dir for a html document with self_contained = TRUE. And it cleans the all directory even if there is something else inside. It seems by design currently.

Maybe an issue could be opened in the rmardown repo to discuss this to be make something compatible with both format at the same time. :thinking:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

Just to follow up, this issue should be fixed in the current development version of rmarkdown now: https://github.com/rstudio/rmarkdown/issues/1503 Thanks!

2 Likes