2

我正在使用一些 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 上的按钮“预览”笔记本,只能编织。

因此,我有两个问题:

  1. 没有这个功能我错过了什么?
  2. 如何复制它知道它是笔记本的上下文 RStudio 行为?

更新:经过更多 IRL 测试后,“预览”按钮似乎可以缓存/预编译材料。我发现对于较大的处理作业,“knit”的单击按钮和获得输出之间的时间比“预览”的时间长,rmarkdown 在控制台窗格的“rmarkdown”选项卡中提供输出

4

1 回答 1

0

将其移至 rstudio 支持页面后,给出了部分解决方案。

---
title: "Report title"
output:
 html_notebook: default
 mypackage::quarterly_report: default
---

上面的 YAML 标头将提供编译为标准、非自定义 RNotebook 的选项,并应用“自定义”格式,并html_document使用第二个参数以样式输出,这些可以通过下拉 knit 按钮随意浏览RSutdio IDE。

于 2017-04-04T12:31:45.433 回答