Learn R Programming

Kmisc (version 0.5.0)

htmlTable: Generate an HTML Table

Description

This function is used to generate an HTML table; it wraps to knitr::kable but gives some 'extras'; in particular, it allows us to set the class, id, and other HTML attributes.

Usage

htmlTable(x, class = "table table-condensed table-hover", id = NULL, style = NULL, attr = NULL, output = TRUE, ...)

Arguments

x
A data.frame or matrix.
class
The CSS class to give the table. By default, we use Twitter bootstrap styling -- for this to take effect, your document must include bootstrap CSS.
id
The CSS id to give the table.
style
Custom styling to apply to the table.
attr
Other attributes we wish to apply to the table.
output
Whether we should write the output to the console. We hijack the kable argument.
...
Optional arguments passed to kable.

Examples

Run this code
df <- data.frame(`P Values`=runif(1000), Group=1:1000)
htmlTable( head(df[ order(df$P, decreasing=FALSE), ]) )
## wow! look at all that significance! ...

Run the code above in your browser using DataLab