The built-in version of DataTables in shiny has already supported
numeric ranges. For a numeric column x in data, if you type a,b in the
search box, the data will be filtered using a <= x <= b. The check
boxes are not supported, but you can use regular expressions (more
flexible) to achieve the same thing, e.g. (this example requires the
development version of shiny:
https://groups.google.com/forum/#!topic/shiny-discuss/-0u-wTnq_lA)

library(shiny)
runApp(list(
  ui = fluidPage(
    dataTableOutput("mytable")
  ),
  server = function(input, output) {
    output$mytable = renderDataTable(
      iris[sample(nrow(iris)), ],
      options = list(search = list(regex = TRUE))
    )
  }
))


Then you can search for ^setosa|versicolor$, which means both setosa
and versicolor in the iris data. Or 4,5 in the search box of
Sepal.Length to filter this column. Depending on what you want, this
may or may not be enough.

Regards,
Yihui
--
Yihui Xie <xieyi...@gmail.com>
Web: http://yihui.name


On Wed, Sep 3, 2014 at 7:12 AM, Charles Determan Jr <deter...@umn.edu> wrote:
> Thank you for checking Yihui, on the off chance are you familiar with any
> other methods to filter on multiple conditions?
>
>
> On Tue, Sep 2, 2014 at 11:07 PM, Yihui Xie <x...@yihui.name> wrote:
>>
>> I just tested it and this plugin does not seem to work with the new
>> .DataTable() API in DataTables 1.10.x, so I guess it is unlikely to
>> make it work in (the current development version of) shiny. It is not
>> in the official list of plugins, either:
>> http://www.datatables.net/extensions/index
>>
>> Regards,
>> Yihui
>> --
>> Yihui Xie <xieyi...@gmail.com>
>> Web: http://yihui.name
>>
>>
>> On Tue, Sep 2, 2014 at 11:59 AM, Charles Determan Jr <deter...@umn.edu>
>> wrote:
>> > 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
>
>
>
> Charles

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to