teal_slice
object fully describes filter state and can be used to create,
modify, and delete a filter state. A teal_slice
contains a number of common fields
(all named arguments of teal_slice
), some of which are mandatory, but only
dataname
and either varname
or expr
must be specified, while the others have default
values.
Setting any of the other values to NULL
means that those properties will not be modified
(when setting an existing state) or that they will be determined by data (when creating new a new one).
Entire object is FilterState
class member and can be accessed with FilterState$get_state()
.
A teal_slice
can come in two flavors:
teal_slice_var
-
this describes a typical interactive filter that refers to a single variable, managed by the FilterState
class.
This class is created when varname
is specified.
The object retains all fields specified in the call. id
can be created by default and need not be specified.
teal_slice_expr
-
this describes a filter state that refers to an expression, which can potentially include multiple variables,
managed by the FilterStateExpr
class.
This class is created when expr
is specified.
dataname
and anchored
are retained, fixed
is set to TRUE
, id
becomes mandatory, title
remains optional, while other arguments are disregarded.
A teal_slice can be passed FilterState
/FilterStateExpr
constructors to instantiate an object.
It can also be passed to FilterState$set_state
to modify the state.
However, once a FilterState
is created, only the mutable features can be set with a teal_slice:
selected
, keep_na
and keep_inf
.
Special consideration is given to two fields: fixed
and anchored
.
These are always immutable logical flags that default to FALSE
.
In a FilterState
instantiated with fixed = TRUE
the features
selected
, keep_na
, keep_inf
cannot be changed.
Note that a FilterStateExpr
is always considered to have fixed = TRUE
.
A FilterState
instantiated with anchored = TRUE
cannot be removed.