I have an Rmarkdown file that uses Flexdashboard. When I knit, the HTML file that is rendered acts as if it is self contained: I can email it to someone and it still works. However, I am stuck with the "files" folder in the directory where the markdown report was saved. If I delete the "files" folder, the report is also deleted. I think for a self contained Rmarkdown html file, the behavior should be that the "files" folder is automatically deleted once the report has finished rendering. However, the report remains and seems to still be linked to the "files" folder. Since I run hundreds of these markdown reports, I would rather not be stuck with all these "files" folders that I cannot move or delete without moving or deleting the reports. Anyone know what's going on?
I am using: RStudio 2022.02.0.443
Rmarkdown: 2.12
Flexdashboard: 0.5.2
R: 4.1.3
Can you share a Rmd file where this happen to you ? The folder should be deleted in self contained mode, if everything in its can be made self contained. So it seems something is wrong and without an example we can't look into what.
I actually just figured out the problem. It was caused by having some calls to ggplot() that did not have any geoms associated with them because the data were missing (these reports are run dynamically while drawing from a sql database). The empty plots were for some reason being saved as png files in the "files" folder. The reports looked fine because those plots were empty as expected when there was not data, but the png files were being created for some reason and that overrode the "self contained" call.
So... I wrote some IF statements to only draw the plot if there is actually data and that seemed to solve the problem.
I can still send an example if you want, but I think the problem is solved so I wouldn't want to further waste your time!