DataframeFilteredDataset {teal.slice} | R Documentation |
The DataframeFilteredDataset
R6
class
Description
The DataframeFilteredDataset
R6
class
The DataframeFilteredDataset
R6
class
Super class
teal.slice::FilteredDataset
-> DataframeFilteredDataset
Methods
Public 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$print()
teal.slice::FilteredDataset$srv_active()
teal.slice::FilteredDataset$srv_add()
teal.slice::FilteredDataset$ui_active()
Method new()
Initializes this DataframeFilteredDataset
object.
Usage
DataframeFilteredDataset$new( dataset, dataname, keys = character(0), parent_name = character(0), parent = NULL, join_keys = character(0), label = character(0) )
Arguments
dataset
(
data.frame
) singledata.frame
for which filters are rendered.dataname
(
character(1)
) syntactically valid name given to the dataset.keys
(
character
) optional vector of primary key column names.parent_name
(
character(1)
) name of the parent dataset.parent
(
reactive
) that returns a filtereddata.frame
from otherFilteredDataset
namedparent_name
. Passingparent
results in areactive
link that causes re-filtering of thisdataset
based on the changes inparent
.join_keys
(
character
) vector of names of columns in this dataset to join withparent
dataset. If column names in the parent do not match these, they should be given as the names of this vector.label
(
character(1)
) label to describe the dataset.
Returns
Object of class DataframeFilteredDataset
, invisibly.
Method get_call()
Gets the subset expression.
This function returns subset expressions equivalent to selected items
within each of filter_states
. Configuration of the expressions 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 apply to one argument (...
) in a dplyr::filter
call.
Usage
DataframeFilteredDataset$get_call(sid = "")
Arguments
sid
(
character
) when specified, the method returns code containing conditions calls ofFilterState
objects withsid
different to that of thissid
argument.
Returns
Either a list
of length 1 containing a filter call
, or NULL
.
Method set_filter_state()
Set filter state.
Usage
DataframeFilteredDataset$set_filter_state(state)
Arguments
state
(
teal_slices
)
Returns
NULL
, invisibly.
Method remove_filter_state()
Remove one or more FilterState
form a FilteredDataset
.
Usage
DataframeFilteredDataset$remove_filter_state(state)
Arguments
state
(
teal_slices
) specifyingFilterState
objects to remove;teal_slice
s may contain onlydataname
andvarname
, other elements are ignored
Returns
NULL
, invisibly.
Method ui_add()
UI module to add filter variable for this dataset.
Usage
DataframeFilteredDataset$ui_add(id)
Arguments
id
(
character(1)
)shiny
module instance id.
Returns
shiny.tag
Method get_filter_overview()
Creates row for filter overview in the form of
dataname -- observations (remaining/total)
- data.frame
Usage
DataframeFilteredDataset$get_filter_overview()
Returns
A data.frame
.
Method clone()
The objects of this class are cloneable with this method.
Usage
DataframeFilteredDataset$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
# use non-exported function from teal.slice
DataframeFilteredDataset <- getFromNamespace("DataframeFilteredDataset", "teal.slice")
library(shiny)
ds <- DataframeFilteredDataset$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())
isolate(ds$get_call())
## set_filter_state
dataset <- DataframeFilteredDataset$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)
isolate(dataset$get_filter_state())