DataframeFilteredDataset | R Documentation |
DataframeFilteredDataset
R6
classThe DataframeFilteredDataset
R6
class
The DataframeFilteredDataset
R6
class
teal.slice::FilteredDataset
-> DataframeFilteredDataset
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()
new()
Initializes this DataframeFilteredDataset
object.
DataframeFilteredDataset$new( dataset, dataname, keys = character(0), parent_name = character(0), parent = NULL, join_keys = character(0), label = character(0) )
dataset
(data.frame
)
single data.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 filtered data.frame
from other FilteredDataset
named parent_name
.
Passing parent
results in a reactive
link that causes re-filtering of this dataset
based on the changes in parent
.
join_keys
(character
)
vector of names of columns in this dataset to join with parent
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.
Object of class DataframeFilteredDataset
, invisibly.
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.
DataframeFilteredDataset$get_call(sid = "")
sid
(character
)
when specified, the method returns code containing conditions calls of
FilterState
objects with sid
different to that of this sid
argument.
Either a list
of length 1 containing a filter call
, or NULL
.
set_filter_state()
Set filter state.
DataframeFilteredDataset$set_filter_state(state)
state
(teal_slices
)
NULL
, invisibly.
remove_filter_state()
Remove one or more FilterState
form a FilteredDataset
.
DataframeFilteredDataset$remove_filter_state(state)
state
(teal_slices
)
specifying FilterState
objects to remove;
teal_slice
s may contain only dataname
and varname
, other elements are ignored
NULL
, invisibly.
ui_add()
UI module to add filter variable for this dataset.
DataframeFilteredDataset$ui_add(id)
id
(character(1)
)
shiny
module instance id.
shiny.tag
get_filter_overview()
Creates row for filter overview in the form of
dataname -- observations (remaining/total)
- data.frame
DataframeFilteredDataset$get_filter_overview()
A data.frame
.
clone()
The objects of this class are cloneable with this method.
DataframeFilteredDataset$clone(deep = FALSE)
deep
Whether to make a deep clone.
# 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())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.