使用knitr'时生成目录(toc);s自旋()
我使用knitr的spin()函数生成html报告 有没有办法让spin()以某种方式为注释中嵌入的标题生成目录(toc)使用knitr'时生成目录(toc);s自旋(),r,knitr,knitr-spin,R,Knitr,Knitr Spin,我使用knitr的spin()函数生成html报告 有没有办法让spin()以某种方式为注释中嵌入的标题生成目录(toc) (注意:我不能使用pandoc,必须使用knitr提供的标记和html生成器。)给定spin.R: #' # Heading x=1:10 y=runif(10) #' And now we can do this #' # Fitting lm(y~x) 然后是两个步骤: spin("spin.R",knit=FALSE) knit2html("spin.Rmd"
(注意:我不能使用pandoc,必须使用knitr提供的标记和html生成器。)给定
spin.R
:
#' # Heading
x=1:10
y=runif(10)
#' And now we can do this
#' # Fitting
lm(y~x)
然后是两个步骤:
spin("spin.R",knit=FALSE)
knit2html("spin.Rmd", options = c("toc", markdown::markdownHTMLOptions(TRUE)))
使用toc生成html
信用证:或者,您可以在R脚本顶部添加YAML头,然后在最新版本的RStudio中单击“编译笔记本”按钮。示例YAML是:
#' ---
#' title: "My Analysis "
#' author: "Me"
#' date: "2016-03-11"
#' output:
#' word_document:
#' reference_docx: knitr_template.docx
#' toc: true
#' always_allow_html: yes
#' ---
你如何在旋转脚本中标记标题?能给我们一些示例代码吗?