The DefaultFilteredDataset R6 class
DefaultFilteredDataset.RdThe DefaultFilteredDataset R6 class
The DefaultFilteredDataset R6 class
Super class
teal.slice::FilteredDataset -> DefaultFilteredDataset
Methods
Inherited methods
teal.slice::FilteredDataset$clear_filter_states()teal.slice::FilteredDataset$format()teal.slice::FilteredDataset$get_dataname()teal.slice::FilteredDataset$get_dataset()teal.slice::FilteredDataset$get_dataset_label()teal.slice::FilteredDataset$get_filter_count()teal.slice::FilteredDataset$get_filter_state()teal.slice::FilteredDataset$get_keys()teal.slice::FilteredDataset$get_metadata()teal.slice::FilteredDataset$print()teal.slice::FilteredDataset$srv_active()teal.slice::FilteredDataset$srv_add()teal.slice::FilteredDataset$ui_active()
Method new()
Initializes this DefaultFilteredDataset object
Usage
DefaultFilteredDataset$new(
dataset,
dataname,
keys = character(0),
parent_name = character(0),
parent = NULL,
join_keys = character(0),
label = character(0),
metadata = NULL
)Arguments
dataset(
data.frame)
single data.frame for which filters are rendereddataname(
character)
A given name for the dataset it may not contain spaceskeysoptional, (
character)
Vector with primary keysparent_name(
character(1))
Name of the parent datasetparent(
reactive)
object returned by this reactive is a filtereddata.framefrom otherFilteredDatasetnamedparent_name. Consequence of passingparentis areactivelink which causes causing re-filtering of thisdatasetbased on the changes inparent.join_keys(
character)
Name of the columns in this dataset to join withparentdataset. If the column names are different if both datasets then the names of the vector define theparentcolumns.label(
character)
Label to describe the datasetmetadata(named
listorNULL)
Field containing metadata about the dataset. Each element of the list should be atomic and length one.
Method get_call()
Gets the filter expression
This functions returns filter calls equivalent to selected items
within each of filter_states. Configuration of the calls is constant and
depends on filter_states type and order which are set during initialization.
This class contains single FilterStates
which contains single state_list and all FilterState objects
applies to one argument (...) in dplyr::filter call.
Method set_filter_state()
Set filter state
Examples
dataset <- teal.slice:::DefaultFilteredDataset$new(iris, "iris")
fs <- teal_slices(
teal_slice(dataname = "iris", varname = "Species", selected = "virginica"),
teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5))
)
dataset$set_filter_state(state = fs)
shiny::isolate(dataset$get_filter_state())
Method remove_filter_state()
Remove one or more FilterState form a FilteredDataset
Method ui_add()
UI module to add filter variable for this dataset
UI module to add filter variable for this dataset
Method get_filter_overview()
Get number of observations based on given keys
The output shows the comparison between filtered_dataset
function parameter and the dataset inside self
Examples
library(shiny)
ds <- teal.slice:::DefaultFilteredDataset$new(iris, "iris")
ds$set_filter_state(
teal_slices(
teal_slice(dataname = "iris", varname = "Species", selected = "virginica"),
teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5))
)
)
isolate(ds$get_filter_state())
#> {
#> "slices": [
#> {
#> "dataname" : "iris",
#> "varname" : "Species",
#> "id" : "iris Species",
#> "choices" : ["setosa", "versicolor", "virgin...
#> "selected" : ["virginica"],
#> "fixed" : false,
#> "anchored" : false,
#> "multiple" : true
#> },
#> {
#> "dataname" : "iris",
#> "varname" : "Petal.Length",
#> "id" : "iris Petal.Length",
#> "choices" : [1, 6.9000000000000004],
#> "selected" : [2, 5],
#> "fixed" : false,
#> "anchored" : false,
#> "multiple" : true
#> }
#> ],
#> "attributes": {
#> "include_varnames" : {
#> "iris" : ["Sepal.Length", "Sepal.Width", ...
#> },
#> "count_type" : "none",
#> "allow_add" : true
#> }
#> }
isolate(ds$get_call())
#> $filter
#> iris <- dplyr::filter(iris, Species == "virginica" & (Petal.Length >=
#> 2 & Petal.Length <= 5))
#>
## ------------------------------------------------
## Method `DefaultFilteredDataset$set_filter_state`
## ------------------------------------------------
dataset <- teal.slice:::DefaultFilteredDataset$new(iris, "iris")
fs <- teal_slices(
teal_slice(dataname = "iris", varname = "Species", selected = "virginica"),
teal_slice(dataname = "iris", varname = "Petal.Length", selected = c(2.0, 5))
)
dataset$set_filter_state(state = fs)
shiny::isolate(dataset$get_filter_state())
#> {
#> "slices": [
#> {
#> "dataname" : "iris",
#> "varname" : "Species",
#> "id" : "iris Species",
#> "choices" : ["setosa", "versicolor", "virgin...
#> "selected" : ["virginica"],
#> "fixed" : false,
#> "anchored" : false,
#> "multiple" : true
#> },
#> {
#> "dataname" : "iris",
#> "varname" : "Petal.Length",
#> "id" : "iris Petal.Length",
#> "choices" : [1, 6.9000000000000004],
#> "selected" : [2, 5],
#> "fixed" : false,
#> "anchored" : false,
#> "multiple" : true
#> }
#> ],
#> "attributes": {
#> "include_varnames" : {
#> "iris" : ["Sepal.Length", "Sepal.Width", ...
#> },
#> "count_type" : "none",
#> "allow_add" : true
#> }
#> }