Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In RStudio, where is knitr markdown output located?

In RStudio, I set the knit option to current folder :
see knitr option

When I knit a Markdown document to HTML, this surprisingly happens in a temporary directory (for example : 'Temp\RtmpOa3xSM\preview-11e8c6644fdd.dir' directory).

As far as I can remember, this didn't happen previously : the knit would happen in the directory I selected in the options.

Option rstudio.markdownToHTML isn't set :

getOption('rstudio.markdownToHTML')
NULL

When I close the HTML preview, the HTML document disappears.

The only solution I found to keep the HTML document is to open the document in a Browser and to save it from there.

Bug or am I missing something? Thanks for your help!

[EDIT] other Win 10 users reported to me the same problem

like image 266
Waldi Avatar asked Jan 24 '23 23:01

Waldi


1 Answers

Under certain conditions, RStudio moves the knitted (HTML or PDF) file to a temporary directory (located under tempdir()). These conditions are:

  • You are in a RStudio Project.
  • The "Project build tools" are set to "Package".
  • The RMD file is located in a subdirectory vignettes.
  • Knitting is initiated with the "Knit" button in RStudio.

Typically, this happens when knitting a package vignette and has the purpose of "keep[ing] your vignettes folder from becoming cluttered with HTML files".

Changing the Project build tools, changing the folder name or closing the project prevents this behavior. Another way to keep the generated (HTML or PDF) file is to call rmarkdown::render interactively (although this is not exactly equivalent to the "Knit" button).

Note that this only affects where the generated file will be saved. The Working Directory while knitting is unaffected.

like image 113
CL. Avatar answered Jan 29 '23 16:01

CL.