来自r的QUARTO_RENDER呈现QMD文件的两个问题
我有一个文件my_file_to_render.qmd用rstudio编写。在wrapper.ri中使用:
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')
我遇到了两个我无法解决的问题。
- 我发现html文件确实确实出现在子目录的“ html”中,但是我想要的是my_file_to_render_20220523.html附带的文件夹仍然出现在工作目录中。因此,当我打开my_file_to_render_20220523.html图片和格式时,丢失了。有什么建议吗?
- 我需要将格式存储到HTML文件的文件夹具有相同的名称。我需要文件my_file_to_render_20220523在文件夹中查看my_file_to_render_20220523和my_file_to_render_20220522以找到文件夹my_file_to_to_render_20220522。目前没有工作。
有人可以帮忙吗?
菲尔,
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.
- 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?
- 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,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您遇到的主要问题是四分之一目前对其渲染的文件夹相当具体。
四分之一在目录结构上做出了许多假设,并且呈现到其他文件夹可能会破坏它。理想情况下,我们不允许输出文件在不同的文件夹上并将其标记为错误,但是现在我们并没有阻止这一点。我建议您首先渲染到另一个名称,然后将文件和移动到您想要的地方。
如果您首先将它们渲染到相同文件夹中的不同文件名,则您的建议应该有效。
The main issue you're running into is that Quarto is currently fairly particular about the folders it renders to.
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.
What you're suggesting should work if you first render them to different file names in the same folder.
我也遇到了同样的问题,这里也在这里的四分之一-CLI讨论论坛上进行了讨论: https://github.com/quarto-dev/quarto-cli/discussions/2171
我的解决方案是编写我自己的功能,它是围绕
QUARTO :: QUARTO_RENDER(QUARTO_RENDER()
)这只是将渲染的输出移至所需的output_dir
。我命名函数QUARTO_RENDER_MOVE()
,然后将其放入我的个人r软件包 。您可以在 httpps://github.com/jhelvy/ JPH/BLOB/MASTER/R/QUARTO_RENDER_MOVE.R这是功能代码:
I had this same problem, which is also discussed in the quarto-cli discussion forums here: https://github.com/quarto-dev/quarto-cli/discussions/2171
My solution was to write my own function which is a wrapper around
quarto::quarto_render()
that simply moves the rendered output to a desiredoutput_dir
. I named the functionquarto_render_move()
and put it in my personal R package {jph}. You can see the function at https://github.com/jhelvy/jph/blob/master/R/quarto_render_move.RHere is the function code: