Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default location of generated html file using knitr and RStudio varies strangely

Tags:

Create a new RStudio project of type package. Create a vignettes directory.

Create two new R Markdown templates. One in the top level of the package (same level as DESCRIPTION) and one in the vignettes directory. knit both to html.

The resulting html file for the first .Rmd is right next to the .Rmd, at the highest level of the package. This is the behavior I expect.

The resulting html file for the second .Rmd is, for me, placed in a temporary directory like:

/private/var/folders/mk/lh99bg295msg8myvcf5yczkc0000gn/T/RtmpDNga3D/preview-152834fe09ff.dir/Untitled.html

and not in the vignettes directory.

  1. Is this the intended behavior? Any pointers to the appropriate documentation appreciated!

  2. Is there an easy way to change this? I would prefer the same behavior in the vignettes directory (create the hmtl and leave it right there) that I see in the top level directory.

I am on a Mac.

like image 984
David Kane Avatar asked Feb 13 '18 19:02

David Kane


1 Answers

Yes, this is intended. It's to keep your vignettes folder from becoming cluttered with HTML files. RStudio renders all package documentation Rmds to temporary files. If you're curious the relevant code is here:

https://github.com/rstudio/rstudio/blob/6056d36192c0a4d1381e5b4f5a3cb8594a2ce97e/src/gwt/src/org/rstudio/studio/client/workbench/views/source/editors/text/TextEditingTarget.java#L5220-L5234

There's no option to change this behavior, but it only engages when you are using RStudio's package building tools. If you want to temporarily disable it, you can go to your Project Options and change Build Tools to None (although this will of course disable other package-building affordances temporarily as well!).

like image 190
Jonathan Avatar answered Oct 11 '22 12:10

Jonathan