knitr HTML Template | Example html Document

Using knitr in conjunction with Rmarkdown and RStudio one can produce nice html reports and material for long presentations where pagination into customary slides becomes tedious. With the RStudio html report format you can also incorporate caching to improve execution time, and include somewhat interactive plotly and other Javascript-based graphics. You can easily produce a floating table of contents. The usual floating TOC in RStudio puts the TOC in the left margin, which uses a lot of real estate and results in a narrower working space. Tom Stewart has adapted the html styles to place the floating TOC in the right margin where it collides less often with graphics and text in the report, and the TOC can be clicked off and on.

Here is a recommended template for reports and presentations. You'll see in the button id line the text you will click on to expand or contract the TOC (here, "Outline"). To compile into an html document, use knit to html in Rstudio.
title: "Report Title" author: "Your Name
Department of Biostatistics
Vanderbilt University School of Medicine
" date: "`r Sys.Date()`" output: html_document: toc: yes toc_depth: 3 number_sections: true toc_float:
collapsed
false code_folding: hide theme: cerulean
css: stewarttoc.css code_folding: hide description: "some description ..."

```{r setup,echo=FALSE} require(Hmisc) # provides knitrSet and other functions knitrSet(lang='markdown', fig.path='png/', fig.align='left', w=6.5, h=4.5, cache=TRUE)

```

Put the attached stewarttoc.css file in your project directory. Ideally this would be placed in a central location on your computer and symbolically linked to from each project.
Topic attachments
I Attachment Action Size Date Who Comment
stewarttoc.csscss stewarttoc.css manage 0.5 K 02 Jan 2018 - 17:43 FrankHarrell CSS style file for floating TOC in right margin of R html reports
Edit | Attach | Print version | History: r12 | r4 < r3 < r2 < r1 | Backlinks | View wiki text | Edit WikiText | More topic actions...
Topic revision: r3 - 05 Jan 2018, FrankHarrell
 

This site is powered by FoswikiCopyright © 2013-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Vanderbilt Biostatistics Wiki? Send feedback