Two problems rendering a qmd file with quarto_render from R

Viewed 1130

I have a file my_file_to_render.qmd written in RStudio with R. I am trying to render this file with output html format from a file wrapper.R. In wrapper.R I am using:

a_param = "a_name"
quarto_render(input = "my_file_to_render.qmd",
       output_file = paste0(".\\HTML\\my_file_to_render","_",today(), '.html'),
       execute_params =list(pcn = a_param), 
       output_format='html')

I'm encountering two problem which I can't work out.

  1. I find that the html file does indeed appear in sub-directory 'HTML' as I want however the folder that accompanies my_file_to_render_20220523.html still appears in the working directory. Hence when I open my_file_to_render_20220523.html pictures and formatting are missing. Any suggestions?
  2. I need the folder which stores the formatting to the html file to have the same name. I need file my_file_to_render_20220523 to look in folder my_file_to_render_20220523 and my_file_to_render_20220522 to find the folder my_file_to_render_20220522. Currently that isn't working out.

Could anybody help?

Phil,

1 Answers

The main issue you're running into is that Quarto is currently fairly particular about the folders it renders to.

  1. Quarto makes a number of assumptions on the directory structure, and rendering to a different folder will probably break that. Ideally we wouldn't allow output files to be on different folders and flag that as an error, but right now we are not preventing that. I suggest you first render to a different name, and then move the file and its folders wherever you want.

  2. What you're suggesting should work if you first render them to different file names in the same folder.

Related