简体   繁体   English

使用来自 R 的 quarto_render 渲染 qmd 文件的两个问题

[英]Two problems rendering a qmd file with quarto_render from R

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.我有一个用 RStudio 和 R 编写的文件 my_file_to_render.qmd。我试图用 output html 格式从文件 wrapper.R 渲染这个文件。 In wrapper.R I am using:在 wrapper.R 我正在使用:

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.我发现 html 文件确实按照我的意愿出现在子目录“HTML”中,但是 my_file_to_render_20220523.html 附带的文件夹仍然出现在工作目录中。 Hence when I open my_file_to_render_20220523.html pictures and formatting are missing.因此,当我打开 my_file_to_render_20220523.html 时,图片和格式都丢失了。 Any suggestions?有什么建议么?
  2. I need the folder which stores the formatting to the html file to have the same name.我需要将格式存储到 html 文件的文件夹具有相同的名称。 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.我需要文件 my_file_to_render_20220523 在文件夹 my_file_to_render_20220523 和 my_file_to_render_20220522 中查找文件夹 my_file_to_render_20220522。 Currently that isn't working out.目前这还行不通。

Could anybody help?有人可以帮忙吗?

Phil,菲尔,

The main issue you're running into is that Quarto is currently fairly particular about the folders it renders to.您遇到的主要问题是 Quarto 目前对它呈现的文件夹相当挑剔。

  1. Quarto makes a number of assumptions on the directory structure, and rendering to a different folder will probably break that. Quarto 对目录结构做了一些假设,渲染到不同的文件夹可能会破坏它。 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.理想情况下,我们不允许 output 文件位于不同的文件夹中并将其标记为错误,但现在我们并没有阻止这种情况。 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.如果您首先将它们呈现为同一文件夹中的不同文件名,那么您的建议应该有效。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM