The R package DT uses the datatables JavaScript library to draw nice-looking tables. I can determine the formatting of the cells in the table using the formatStyle() function, but there does not seem to be a function to format the column headers. Is there a way to format the headers of the table, for example fonts, alignments etc?
Many questions about DT on Stack Overflow are specific to R Shiny, and I am not using R Shiny.
The R package DT provides an R interface to the JavaScript library DataTables. R data objects (matrices or data frames) can be displayed as tables on HTML pages, and DataTables provides filtering, pagination, sorting, and many other features in the tables.
fixedHeader-floating"). scrollLeft( $(this). scrollLeft() ); } }); DataTables creates a new table as the fixedHeader when you scroll down, what I'm doing here is to detect when the user scrolls horizontally on the $('#example') table and then I use scrollLeft() on the fixedHeader to match the scroll position.
DT is an interface to the JavaScript library DataTables based on the htmlwidgets framework, to present rectangular R data objects (such as data frames and matrices) as HTML tables. You can filter, search, and sort the data in the table.
You may use the "initComplete" function in "options" to callback a javascript code directly. Try the following R code to format the column headers to a 12 pixels font size:
datatable(
iris,
options = list(
initComplete = JS("function(settings, json) {$(this.api().table().header()).css({'font-size' : '12px'});}")
)
)
There are many other examples at http://rstudio.github.io/DT/
Regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With