Convenience functions to generate a table header (<thead></thead>) or
footer (<tfoot></tfoot>) given the column names. They are basically
wrappers of htmltools::tags$th applied to the column names.
tableHeader(names, escape = TRUE) tableFooter(names, escape = TRUE)
| names | a character vector of the column names of the table (if it is an object with column names, its column names will be used instead) |
|---|---|
| escape | whether to escape the names (see |
A tag object generated by htmltools::tags.
library(DT) tableHeader(iris) # or equivalently, #> <thead> #> <tr> #> <th>Sepal.Length</th> #> <th>Sepal.Width</th> #> <th>Petal.Length</th> #> <th>Petal.Width</th> #> <th>Species</th> #> </tr> #> </thead> tableHeader(colnames(iris)) #> <thead> #> <tr> #> <th>Sepal.Length</th> #> <th>Sepal.Width</th> #> <th>Petal.Length</th> #> <th>Petal.Width</th> #> <th>Species</th> #> </tr> #> </thead> tableFooter(iris) # footer #> <tfoot> #> <tr> #> <th>Sepal.Length</th> #> <th>Sepal.Width</th> #> <th>Petal.Length</th> #> <th>Petal.Width</th> #> <th>Species</th> #> </tr> #> </tfoot> library(htmltools) tags$table(tableHeader(iris), tableFooter(iris)) #> <table> #> <thead> #> <tr> #> <th>Sepal.Length</th> #> <th>Sepal.Width</th> #> <th>Petal.Length</th> #> <th>Petal.Width</th> #> <th>Species</th> #> </tr> #> </thead> #> <tfoot> #> <tr> #> <th>Sepal.Length</th> #> <th>Sepal.Width</th> #> <th>Petal.Length</th> #> <th>Petal.Width</th> #> <th>Species</th> #> </tr> #> </tfoot> #> </table>