We are happy to announce a new package DT is available on CRAN now. 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. See http://rstudio.github.io/DT/ for the full documentation and examples of this package. To install the package, run

install.packages('DT')
# run DT::datatable(iris) to see a "hello world" example


The main function in this package is datatable(), which returns a table widget that can be rendered in R Markdown documents, Shiny apps, and the R console. It is easy to customize the style (cell borders, row striping, and row highlighting, etc), theme (default or Bootstrap), row/column names, table caption, and so on.

## DataTables Options

The DataTables library supports a large number of initialization options. Through DT, you can specify these options using a list in R. For example, we can disable searching, change the default page length from 10 to 5, and customize the length menu to use page lengths 5, 10, 15, and 20:

library(DT)
datatable(iris, options = list(
searching = FALSE,
pageLength = 5,
lengthMenu = c(5, 10, 15, 20)
))


When you need to write literal JavaScript code in these options (e.g. the callback functions), you can use the JS() function. An example of the initComplete callback:

datatable(iris, options = list(
initComplete = JS("
function(settings, json) {

## DataTables Extensions

DataTables has several extensions, and we have integrated all of them into DT. You may enable extensions via the extensions argument of datatable(). For example, you can reorder columns using the ColReorder extension, show/hide columns using the ColVis extension, fix certain columns on the left and/or right via FixedColumns when scrolling horizontally in the table, and so on. Please see the documentation page for extensions for details.

We hope you will enjoy this package, and please let us know if you have any questions, comments, or feature requests.