• Stars
    star
    273
  • Rank 150,043 (Top 3 %)
  • Language
    HTML
  • License
    Other
  • Created over 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A framework to create bootstrap styled HTML reports from knitr Rmarkdown.

Knitr Bootstrap

A framework to create bootstrap styled HTML reports from knitr Rmarkdown.

Table of Contents

Features

  • Uses bootstrap 3.0, should work for all screen sizes.
  • Automatic table of contents constructed from h1-4 tags.
  • Images are automatically centered, thumbnailed and lightboxed using magnific popup.
  • Style with themes from bootswatch, optionally including a dynamic style switch.
  • Code blocks automatically highlighted using highlight.js, optionally including a dynamic style switch.
  • Code/Output block and plot visibility can be toggled with a mouse click
    • Globally
    • Per language
  • Create completely offline reports, including all css, javascript and images
  • Mathematical equations using mathjax, note this does not work offline

Examples

All the examples include a css style switch, so you can try out the various styles from bootswatch.

  • 2d - examples of miscellaneous 2d
  • cars - using ggplot2 and the cars dataset
  • engines - using other language engines
  • illusions - examples of interesting optical illusions
  • maps - examples of map plots, and holding plots until end of the block
  • math - examples of MathJax formulas
  • all - All examples together

Installation

If you want to install the latest development version use the devtools package to install the rmarkdown and knitr (devel) prerequisites and this package.

library(devtools)
install_github('rstudio/rmarkdown')
install.packages('knitr', repos = c('http://rforge.net', 'http://cran.rstudio.org'),
                 type = 'source')
install_github('jimhester/knitrBootstrap')

You can install the latest released version from CRAN. Typically lags behind latest by a good amount.

install.packages('knitrBootstrap')

Usage

Knitr Bootstrap includes a knitrBootstrap::bootstrap_document custom rendering function for use with the Rmarkdown package.

RStudio

Very current versions of RStudio use the render function when you press the "Knit" button. In order to output using knitrBootstrap use the YAML front-matter in your document.

YAML Front-matter

You can also specify the bootstrap_document function as an output type along with the options in the YAML front-matter directly in your Rmd file. All of the global Package Options can be specified in the front matter.

---
output:
  knitrBootstrap::bootstrap_document:
    title: "Test file"
    theme: amelia
    highlight: sunburst
    theme.chooser: TRUE
    highlight.chooser: TRUE
---

Render Function

You can also simply call the render function by itself.

library(knitrBootstrap)
library(rmarkdown)
render('file.Rmd', 'knitrBootstrap::bootstrap_document')

Vim

Using the Vim-R-Plugin put the following function in your .vimrc to create the file directly with knitr and the markdown package

function! RMakeHTML_2()
  update
  call RSetWD()
  let filename = expand("%:r:t")
  let rcmd = "require('knitrBootstrap');\
    render(\"" . filename . ".Rmd\", knitrBootstrap::bootstrap_document)"
  if g:vimrplugin_openhtml
    let rcmd = rcmd . '; browseURL("' . filename . '.html")'
  endif
  call g:SendCmdToR(rcmd)
endfunction

"bind RMakeHTML_2 to leader kk
nnoremap <silent> <Leader>kk :call RMakeHTML_2()<CR>

Makefile

You can use the included Makefile to generate html reports from Rmd files from the command line. If you have a file file.Rmd and you want to create file.html use

#standard
make file.html

#with bootstrap style chooser
make THEME_CHOOSER=TRUE file.html

#with code style chooser
make HIGHLIGHT_CHOOSER=TRUE file.html

#with both
make HIGHLIGHT_CHOOSER=TRUE THEME_CHOOSER=TRUE file.html

#standalone
make file_inline.html

Options

Knitr bootstrap extends knitr with a number of additional options. See Knitr Options for more about how to set the two different types of options.

Package Options

  • bootstrap.title - (NULL) Set the title for the html document
  • bootstrap.theme.chooser - (FALSE) - Add a bootstrap style chooser to the page.
  • bootstrap.highlight.chooser - (FALSE) - Add a code style chooser to the page.
  • bootstrap.theme - (Default) - Set the default bootstrap style.
  • bootstrap.highlight - (HighlightJS) - Set the default code style.
  • bootstrap.menu - (TRUE) - Whether to include the bottom navbar.
  • custom.header - (NULL) - External HTML header contents to include in header block.
  • clean_supporting - (TRUE) - Clean the intermediate supporting documents. (this is only an option for the bootstap_document function)

Chunk Options

  • bootstrap.thumbnail - (TRUE) - Thumbnail and lightbox images.
  • bootstrap.thumbnail.size - ('col-md-6') - Thumbnail size in bootstrap columns. (see Bootstrap Grid System)
  • bootstrap.panel - (FALSE) - Use panels rather than buttons to toggle blocks.
  • bootstrap.show.code - (TRUE) - Code from this chunk starts as shown.
  • bootstrap.show.output - (TRUE) - Output from this chunk starts as shown.
  • bootstrap.show.message - (TRUE) - message from this chunk starts as shown.
  • bootstrap.show.warning - (TRUE) - warning from this chunk starts as shown.
  • bootstrap.show.error - (TRUE) - error from this chunk starts as shown.
  • bootstrap.class - ('row') - Bootstrap class to apply to the div containing the chunk.

Bootstrap Themes

Highlight Themes

Highlight Live Test

  • HighlightJs
  • Dark
  • Far
  • Idea
  • Sunburst
  • Zenburn
  • Visual Studio
  • Ascetic
  • Magula
  • Github
  • Google Code
  • Brown Paper
  • School Book
  • IR Black
  • Solarized - Dark
  • Solarized - Light
  • Arta
  • Monokai
  • Xcode
  • Pojoaque
  • Rainbow
  • Tomorrow
  • Tomorrow Night
  • Tomorrow Night Bright
  • Tomorrow Night Blue
  • Tomorrow Night Eighties

More Repositories

1

per-directory-history

Per directory history for zsh, as well as global history, and the ability to toggle between them with ^G.
Shell
221
star
2

lookup

Lookup R full function definitions, including compiled code, S3 and S4 methods.
R
206
star
3

presentations

Just a place to store and link to presentations I have done
JavaScript
63
star
4

autoinst

Automatically install packages when they are missing
R
54
star
5

fasta_utilities

A collection of scripts developed to interact with fasta, fastq and sam/bam files.
Perl
50
star
6

completeme

WIP
R
38
star
7

rarrow

R bindings to apache arrow
C++
32
star
8

typeCheck

The typeCheck package automatically adds type checking code when types are annotated.
R
26
star
9

dotfiles

Vim Script
23
star
10

lambda

Simple anonymous functions
R
20
star
11

plyrToDplyr

R
20
star
12

regulaR

Regular expressions for humans, a port of Ruby's Regularity library to R (see https://github.com/kevinushey/rex for current development)
R
20
star
13

cran_usage

R
19
star
14

altparsers

C
19
star
15

jimhester.com

HTML
15
star
16

SublimeLinter-contrib-lintr

Python
14
star
17

thank

Give Thanks
R
13
star
18

setup-r

Set up your GitHub Actions workflow with a specific version of R
JavaScript
12
star
19

wercker-r-example

Example of an R project using wercker
12
star
20

r-actions-test

https://jimhester.github.io/r-actions-test/
C
11
star
21

highlite

A Highlighting Library For R
C++
11
star
22

ggplot2ToGgvis

R
11
star
23

bloom

R Bloom filter implementation using Rcpp bindings for dabloom.
C
9
star
24

ida-scripts

collection of scripts for ida pro
Perl
9
star
25

dwarftherapist

Dwarf Therapist is an extension application for the fantastic game Dwarf Fortress. DF is a great game. And it's fun to manage dwarves with keyboard menus until about the 50th one shows up. If you're starting to get overwhelmed you need therapist in your life.
C++
9
star
26

tomatoa

I'd rather be shiny
R
7
star
27

subsetr

Drop-in replacements for `[.data.frame` and `subset.data.frame` with robust non-standard evaluation
R
7
star
28

analysis_framework

A skeleton analysis framework for use with knitr and git.
Perl
6
star
29

note

Play music
R
6
star
30

rtreesitter

R bindings to the Tree-sitter parsing library
Rust
6
star
31

test-glfs

5
star
32

benchthat

Track performance benchmarks for a package over time
R
4
star
33

wercker-step-r-dependencies

Wercker step to install R dependencies
Shell
4
star
34

predpipe

Predict the next pipe function from the previous functions in the chain.
R
3
star
35

stonesense

A retro isometric visualizer for Dwarf Fortress
C++
2
star
36

flickrr

Minimal R API for flickr
R
2
star
37

wercker-step-r-check

Wercker step to check an R package
Shell
2
star
38

dplyrJDBC

JDBC driver for dplyr
R
2
star
39

ex

Example package for using multiple parsers
R
2
star
40

perlrer

Input perl regular expression, get perl results in R!
R
2
star
41

BiocInstaller2

R
1
star
42

copyfile

Investigate a strange bug in copyfile
C
1
star
43

surveillance

mirror of the surveillance package for testing
R
1
star
44

poc-testthat2020

R
1
star
45

wercker-step-r-lint

Wercker step to run R lint
Shell
1
star
46

hashsize

Benchmarks of the R symbol table hashmap
C
1
star
47

BAMSpector

R
1
star
48

TypeTracker

Tracks your typing, and generates typing lessons to improve your typing ability
C++
1
star
49

wercker-step-r-coverage

Wercker step to run R coverage
Shell
1
star
50

aws-check

Shell
1
star
51

Dwarf-Clipboard

Application for Dwarf Fortress to copy parts of a fort and paste them into other locations/forts
C++
1
star