[R] shiny datatables column filtering plugin

Charles Determan Jr deter088 at umn.edu
Tue Sep 2 18:59:24 CEST 2014


Greetings,

I am currently exploring some capabilities of the 'Shiny' package.  I am
currently working with the most recent version of 'shiny' from the rstudio
github repository (version - 0.10.1.9006) in order to use the most up to
date datatables plugin.  Using the ggplot2 diamonds dataset, I can easily
set columns as unsearchable (commented out below) and I could also subset
out all the 'Ideal' diamonds for example, however I cannot filter out
multiple conditions such as 'Ideal' and 'Fair' diamonds together.  From my
searching, this multiple filtering can be done with checkboxes from the
column using the jquery column filtering plugin (
http://jquery-datatables-column-filter.googlecode.com/svn/trunk/checkbox.html).
Despite this, I cannot get this plugin to work with my shiny app.  Any
insight would be appreciated.

library(shiny)
library(ggplot2)
runApp(
  list(ui = basicPage(
    h1('Diamonds DataTable with TableTools'),

    # added column filter plugin
    singleton(tags$head(tags$script(src='https://code.google.com/p/jquery-datatables-column-filter/source/browse/trunk/media/js/jquery.dataTables.columnFilter.js',
type='text/javascript'))),
    dataTableOutput("mytable")
  )
  ,server = function(input, output) {
    output$mytable = renderDataTable({
      diamonds[,1:6]
    }, options = list(
      pageLength = 10,#       columnDefs = I('[{"targets": [0,1],
"searchable": false}]')
      columnFilter = I('[{
                        columnDefs: ["targets": [0,1], type: "checkbox"]
                        }]')

    )
    )
  }
  ))



Charles

	[[alternative HTML version deleted]]



More information about the R-help mailing list