Repository navigation
Closed
Description
From a question on Rstudio community, it seems that default behaviour for html_document is to delete the whole files_dir of the form *_files even if something else from other format is there.
I tried to come up with a reprex for this. See below
github_documentgenerate a figure that lives in afigure-gfmfolder, required to use with the md file generatedhtml_documentby default isself_contained=TRUE, so cleaning is activated (unlessclean = FALSEinrender. The cleaning process suppress the wholefiles_dir, *including thefigure-gfm- using output format
"all"to generate both format shows that everything is deleted and the png file for the plot does not exist anymore for the github_document format.
# create temporary directory to work in for example
dir_temp <- fs::path_temp("rmd")
fs::dir_create(dir_temp)
# create test rmd file
test_rmd <- fs::file_temp("test", dir_temp, ext = ".Rmd")
writeLines(c('---
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)
```
'), test_rmd)
fs::dir_ls(dir_temp)
# creating plot file in a new folder
rmarkdown::render(test_rmd, "github_document")
fs::dir_ls(dir_temp, regexp = "_files", recursive = TRUE)
# without clean the dir is here
rmarkdown::render(test_rmd, "html_document", clean = FALSE)
fs::dir_ls(dir_temp, regexp = "_files", recursive = TRUE)
# with default clean = TRUE, the whole dir is deleted, even the file from github_document format.
rmarkdown::render(test_rmd, "html_document")
fs::dir_ls(dir_temp, regexp = "_files", recursive = TRUE)
fs::dir_ls(dir_temp, recursive = TRUE)
# no folder for github document containing the image
rmarkdown::render(test_rmd, "all")
fs::dir_ls(dir_temp, regexp = "_files", recursive = TRUE)
fs::dir_ls(dir_temp, recursive = TRUE)
# both folder are present
rmarkdown::render(test_rmd, "all", clean = FALSE)
fs::dir_ls(dir_temp, regexp = "_files", recursive = TRUE)
fs::dir_ls(dir_temp, recursive = TRUE)
# clean
unlink(dir_temp, recursive = TRUE)There are different argument fir a workaround (clean = FALSE, or self_contained: false, change fig_path location) that will prevent that, but seems like an non wanted effect.
What do you think ?
Reacted by Yihui Xie
Activity
yihui commentedon Mar 13, 2019
Duplicate of #1472
yihui commentedon Mar 13, 2019
Should be fixed now. Thanks for the report and the reprex!
fix rstudio#1472: check if the figure-* directory exists under files_…
cderv commentedon Apr 10, 2019
It seems like this is not fixed. I rerun the reprex and the issue still here. I see where it comes from.
I can help with a PR if you want.
github-actions commentedon Nov 3, 2020
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.