A shinyfilters object holds a data.frame and all of the data's filters. To
create one, call shinyfilters(). To modify one, use with_filters(),
with_args(), with_defaults(), or with_ns().
Usage
The object behaves much like the data.frame that defines it.
Subsetting
filters$col creates the input for one filter.
filters[[cols]] creates the inputs for all filters in cols.
filters[cols] subsets a shinyfilters object, returning only filters
matching cols.
shinyfilters supports <tidy-select> in both
[ and [[
In a shiny app
A shinyfilters object can be placed directly inside a ui:
To enable interdependent filters, call shinyfilters_server in the server:
Creating filters
Sometimes, you will have to create the filters as you place them in the app. The following functions create filters:
[[$
Currently, it is known that you must create the filters when:
Bookmarking is enabled
When placing a filter inside bslib::accordion.
In these instances, shinyfilters will intercept and throw an informative error.
accordion(shinyfilters(nyc_flights))
#> Error:
#> ! <shinyfilters> objects cannot be used in some shiny functions.
#> i Use `[[`, `$`, or `filterInput()` to render the filters directly.Printing
Printing shows the input each column receives:
shinyfilters(nyc_flights)
#> <shinyfilters> * 7 filters
#>
#> Filters
#> date <date> dateRangeInput
#> carrier <chr> selectizeInput
#> origin <fct> selectizeInput
#> dest <chr> selectizeInput
#> dep_delay <dbl> sliderInput
#> distance <dbl> sliderInput
#> delayed <lgl> selectizeInputAny modifications will be displayed:
shinyfilters(nyc_flights, range = FALSE) |>
with_filters(date = "date") |>
with_ns("sidebar-mod")
#> <shinyfilters> * 7 filters * namespace "sidebar-mod"
#>
#> Filters
#> * date <date> dateInput
#> carrier <chr> selectizeInput
#> origin <fct> selectizeInput
#> dest <chr> selectizeInput
#> dep_delay <dbl> sliderInput
#> distance <dbl> sliderInput
#> delayed <lgl> selectizeInput
#>
#> Default Overrides
#> range = FALSE
#>
#> * Filter set by `with_filters()`