How can I render a .R file in a random directory

Hello I would like to know how I can render a .R file so that all intermediary .Rmd and other temporary things are generated in a specific location ?
For instance I see a spin.Rmd and temporary html being generated.
I is annoying because

  • I use servr::rmdv2 to render continuously all Rmd from a directory and the temp Rmd created ‘interfere’
  • I’d like to be able to run render(‘my file.R’) from serveral processes with different arguments so I do not want things to clash

Can you give an example with code of your current workflow so that we could understand better ?

In rmarkdown, I believe you can use some argument in render to change the directories but I am not sure what you use. Is it knitr::spin instead ?

Thank you

I just use rmarkdown::render("my_file.R")
This will create a my_file.spin.Rmd intermediary file, I think render calls knitr::spin under the hood to transform the R file into a Rmd file

Yes it does.

This file is deleted usually. When I try I only get .R and .html at the end

You could try changing intermediates_dir = in render

Thanks intermediates_dir did the trick

#' ---                                                                                          
#' title: "Untitled"                                                                            
#' author: "statquant"                                                                          
#' date: "03/10/2020"                                                                           
#' ---                                                                                          
                                                                                                
#+                                                                                              
Sys.sleep(10)                                                                                   
                                                                                                
#' # Section                                                                                    
                                                                                                
#' test I've been doing                                                                         
                                                                                                
#+ test, eval = FALSE                                                                           
#render(input="q2.R") # q2.spin.{R,Rmd,html} in directory                                       
#render(input="q2.R", output_dir = "./output") # q2.spin.{R,Rmd} in directory htmp in output    
#render(input="q2.R", output_dir = "./output", intermediates_dir = "./tmp") # perfect
1 Like

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.