DataframeFilteredDataset: The 'DataframeFilteredDataset' 'R6' class

DataframeFilteredDatasetR 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

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) 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.

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 of FilterState objects with sid different to that of this sid 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) specifying FilterState objects to remove; teal_slices may contain only dataname and varname, 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())


teal.slice documentation built on May 29, 2024, 1:39 a.m.