![](/img/trans.png)
[英]How can I prevent markdown styling of R output in a quarto HTML document
[英]How do I change the default output location of the quarto document in Rstudio?
例如,我的 quarto 文件在D:\myr\index.qmd
,我怎样才能将生成的 output 文件 PDF 文件到E:\myoutput
?
output 文件位置可以使用来自{quarto}
package 的quarto_render()
function 的output_file
参数指定。
所以理想情况下,我们可以尝试这样的事情,
quarto::quarto_render("index.qmd", output_file = "E:/index.pdf")
索引.qmd
---
title: "Untitled"
format: pdf
---
## Quarto
Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see <https://quarto.org>.
## Running Code
When you click the **Render** button a document will be generated that includes both content and the output of embedded code. You can embed code like this:
但这导致我出错,
ERROR: The system cannot move the file to a different disk drive. (os error 17),
rename 'index.pdf' -> 'E:/index.pdf'
版本信息
> xfun::session_info()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044), RStudio 2022.7.1.554
> quarto::quarto_version()
[1] ‘1.0.38’
我们可以使用这个 function 将渲染的 output 文件移动到所需的目录。
render_qmd <- function(input_file, output_path, file_ext, ...) {
# Extract just the input file name (without the file-extension)
file_name <- xfun::sans_ext(input_file)
# render the input document and output file will be in the
# current working directory.
quarto::quarto_render(input = input_file, output_format = file_ext, ...)
# name of the rendered output file
output_name <- paste0(file_name, ".", file_ext)
# move the file to the output path
fs::file_move(paste0(output_name), output_path)
msg <- paste0(paste0(output_name, collapse = " and "), " moved to ", output_path)
message(msg)
}
render_qmd("index.qmd", "E:/myoutput", file_ext = "pdf")
请注意,此 function 中使用了包{quarto}
、 {fs}
、 {xfun}
。 因此,请确保您已安装这些 pkg。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.