Update November 2014
With the new version of knitr and Rmarkdown, the custom function is not necessary anymore. One can add a yaml at the beginning of a Rmd file:---
title: "Development scrap concerning the input data"
output:
html_document:
toc: true
---
Old content from January 2014
Knitr creator Yihui explained in a comment on this forum how to add a table of content to a Rmd file using the knit2html() function:
library(knitr)
knit2html('docs/clean.example.Rmd', options = c('toc', markdown::markdownHTMLOptions(TRUE)))
I followed the RSTUDIO advice on how to
customize markdown rendering.A .Rprofile at the root of my project directory with the following content does the tric:
options(rstudio.markdownToHTML =I works, I can now use the RStudio button "knit html" or the shortcut CTRL+SHIFT+H and get an html file that includes a table of content!
function(inputFile, outputFile) {
require(markdown)
htmlOptions <- defaults="TRUE)<br" markdownhtmloptions=""> htmlOptions <- br="" c="" htmloptions="" toc=""> markdownToHTML(inputFile, outputFile, options = htmlOptions)
}
) ->->
No comments:
Post a Comment