gpt4 book ai didi

r - 通过 RStudio 中的 YAML header 默认 knit 目录?

转载 作者:行者123 更新时间:2023-12-04 01:07:46 24 4
gpt4 key购买 nike

是否有 YAML 选项,可以为 Rmd 文件设置 knit 目录? IE。与图 1 所示的相同。
问题是,每次我复制文件或与其他人共享项目(通常与我的默认 RStudio 选项不同)时,应该在每个文件中手动重置 knit 目录。
我知道全局选项(图 2),但我需要一个更具重现性的解决方案,该解决方案适用于 RStudio 笔记本和编织模式下的单个 Rmd 文件。
而且,例如,我知道有一个选项,例如:

editor_options: 
chunk_output_type: console

有任何想法吗?

enter image description here

图 1 通过菜单命令设置编织目录。

enter image description here

图 2 在 RStudio 中设置默认 knit 目录的全局选项。

最佳答案

您可以尝试指定 knit .Rmd 文件前面的字段。示例 .Rmd 将编织到您的主目录中创建的“some_dir”中:

---
title: "Untitled"
output: html_document
knit: (function(inputFile, encoding) {
rmarkdown::render(inputFile, encoding = encoding, output_dir = "~/some_dir/")
})
---

# Some content

Some content

关于r - 通过 RStudio 中的 YAML header 默认 knit 目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56427501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com