The DefaultFilteredDataset
R6 class
DefaultFilteredDataset.Rd
The DefaultFilteredDataset
R6 class
The DefaultFilteredDataset
R6 class
Super class
teal.slice::FilteredDataset
-> DefaultFilteredDataset
Methods
Inherited methods
teal.slice::FilteredDataset$get_dataname()
teal.slice::FilteredDataset$get_dataset()
teal.slice::FilteredDataset$get_dataset_label()
teal.slice::FilteredDataset$get_filter_overview_info()
teal.slice::FilteredDataset$get_filter_states()
teal.slice::FilteredDataset$get_filterable_varnames()
teal.slice::FilteredDataset$get_filtered_dataname()
teal.slice::FilteredDataset$get_formatted_filter_state()
teal.slice::FilteredDataset$get_hash()
teal.slice::FilteredDataset$get_keys()
teal.slice::FilteredDataset$get_metadata()
teal.slice::FilteredDataset$get_varlabels()
teal.slice::FilteredDataset$get_varnames()
teal.slice::FilteredDataset$queues_empty()
teal.slice::FilteredDataset$server()
teal.slice::FilteredDataset$ui()
Method new()
Initializes this DefaultFilteredDataset
object
Usage
DefaultFilteredDataset$new(
dataset,
dataname,
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 spaceskeys
optional, (
character
)
Vector with primary keyslabel
(
character
)
Label to describe the datasetmetadata
(named
list
orNULL
)
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 ReactiveQueue
and all FilterState
objects
applies to one argument (...
) in dplyr::filter
call.
Method get_filter_state()
Gets the reactive values from the active FilterState
objects.
Get all active filters from this dataset in form of the nested list.
The output list is a compatible input to self$set_filter_state
.
Method set_filter_state()
Set filter state
Arguments
state
(
named list
)
containing values of the initial filter. Values should be relevant to the referred column....
Additional arguments. Note that this is currently not used
Examples
dataset <- teal.slice:::DefaultFilteredDataset$new(iris, "iris")
fs <- list(
Sepal.Length = list(selected = c(5.1, 6.4), keep_na = TRUE, keep_inf = TRUE),
Species = list(selected = c("setosa", "versicolor"), keep_na = FALSE)
)
dataset$set_filter_state(state = fs)
shiny::isolate(dataset$get_filter_state())
Method remove_filter_state()
Remove one or more FilterState
of a FilteredDataset
Method ui_add_filter_state()
UI module to add filter variable for this dataset
UI module to add filter variable for this dataset
Method srv_add_filter_state()
Server module to add filter variable for this dataset
Server module to add filter variable for this dataset.
For this class srv_add_filter_state
calls single module
srv_add_filter_state
from FilterStates
(DefaultFilteredDataset
contains single FilterStates
)
Method get_filter_overview_nsubjs()
Get number of observations based on given keys
The output shows the comparison between filtered_dataset
function parameter and the dataset inside self
Usage
DefaultFilteredDataset$get_filter_overview_nsubjs(
filtered_dataset = self$get_dataset(),
subject_keys = NULL
)
Examples
library(shiny)
ds <- teal.slice:::DefaultFilteredDataset$new(iris, "iris")
ds$set_filter_state(
state = list(
Species = list(selected = "virginica"),
Petal.Length = list(selected = c(2.0, 5))
)
)
#> NULL
isolate(ds$get_filter_state())
#> $Species
#> $Species$selected
#> [1] "virginica"
#>
#> $Species$keep_na
#> [1] FALSE
#>
#>
#> $Petal.Length
#> $Petal.Length$selected
#> [1] 2 5
#>
#> $Petal.Length$keep_na
#> [1] FALSE
#>
#> $Petal.Length$keep_inf
#> [1] FALSE
#>
#>
isolate(ds$get_call())
#> $filter
#> iris_FILTERED <- dplyr::filter(iris, Species == "virginica" &
#> (Petal.Length >= 2 & Petal.Length <= 5))
#>
## ------------------------------------------------
## Method `DefaultFilteredDataset$set_filter_state`
## ------------------------------------------------
dataset <- teal.slice:::DefaultFilteredDataset$new(iris, "iris")
fs <- list(
Sepal.Length = list(selected = c(5.1, 6.4), keep_na = TRUE, keep_inf = TRUE),
Species = list(selected = c("setosa", "versicolor"), keep_na = FALSE)
)
dataset$set_filter_state(state = fs)
#> NULL
shiny::isolate(dataset$get_filter_state())
#> $Sepal.Length
#> $Sepal.Length$selected
#> [1] 5.1 6.4
#>
#> $Sepal.Length$keep_na
#> [1] TRUE
#>
#> $Sepal.Length$keep_inf
#> [1] TRUE
#>
#>
#> $Species
#> $Species$selected
#> [1] "setosa" "versicolor"
#>
#> $Species$keep_na
#> [1] FALSE
#>
#>