我正在使用一些 css 和 html 构建一个自定义格式的笔记本。正如推荐的那样,这是使用围绕 rmarkdown 函数的包装函数来实现的。
quarterly_report <- function(toc = TRUE) {
# get the locations of resource files located within the package
css <- system.file("reports/styles.css", package = "mypackage")
header <- system.file("reports/quarterly/header.html", package = "mypackage")
# call the base html_document function
rmarkdown::html_notebook(toc = toc,
fig_width = 6.5,
fig_height = 4,
theme = NULL,
css = css,
includes = includes(before_body = header))
}
但是,当我以建议的方式使用 YAML 运行它时:
---
title: "Habits"
output:
mypackage::quarterly_report:
toc: true
---
它会运行,但没有选项可以使用 IDE 上的按钮“预览”笔记本,只能编织。
因此,我有两个问题:
- 没有这个功能我错过了什么?
- 如何复制它知道它是笔记本的上下文 RStudio 行为?
更新:经过更多 IRL 测试后,“预览”按钮似乎可以缓存/预编译材料。我发现对于较大的处理作业,“knit”的单击按钮和获得输出之间的时间比“预览”的时间长,rmarkdown 在控制台窗格的“rmarkdown”选项卡中提供输出