The goal of the smart.data package is to provide an API that allows for semantic interaction with tabular data as well as governed manipulation of the same. Each smart.data object is an R6 reference class instance which can be symbolically retrieved from memory cache (see cachem_mem) as well as by direct workspace object invocation.
Before using the smart.data reference class for the first time in a user session, smart.start() needs to be invoked in order to create the smart-cache.
dataA data.table object holding the current state of the data
nameThe label to use to semantically retrieve the smart.data object from cache
idAn auto-generated unique ID for the smart.data object
smart.rulesAn environment holding user-generated sets of rules
get.historyReturns the saved history from calls to $capture()
new()Initialize the class object.
smart.data$new(x, name = "new_data", ...)xThe input data
nameThe name for the smart class when used in smart functions
...Arguments used to initialize the smart cache (see cache_layered and related). If none are provided, the default is to create a memory cache via cache_mem
naming.rule()$naming.rule provides the prescribed laws for renaming the fields found in self$data. The specified fields found in self$data are renamed when the "law" is enforced.
...Key-value pairs denoting the naming scheme: new_name = old_name. Items with no key will be used as its own name. dots_list supported.
show(logical) When TRUE the structure of the rule is printed to console
taxonomy.rule()$taxonomy.rule() sets class object $smart.rules$for_usage which is referenced by method $use(). $taxonomy.rule creates a mapping of fields in $data to labels that can be used to reference them.
Parameter term.map is a data.table object with the following required fields:
...(dots_list) These arguments will add, update, or remove taxonomy entries. Arguments should be taxonomy objects created with taxonomy, a length-1 named list consisting of NULL (which removes existing entries), or a named list with child elements structured as follows:
(character) The name of the taxonomy term
(character) A description for each term's interpretation or context for usage
(string[]) Optionally provided: contains a vector of field names in $data mapped to the term
chatty(logical|FALSE) Should additional information be printed to the console?
gui(logical|FALSE) (ignored)
enforce.rules()$enforce.rules operates on rules saved in $smart.rules and evaluates the quoted "law" on $data. Custom rules can be directly added to class member $smart.rules: they must have an attribute "law" containing a quoted expression referencing object .data and rule. The rule should contain any objects referenced by the quoted expression.
set.private()$set.private operates on the private class list accessed internally as $private using key-value pairs (i.e. key = value)
use()$use takes as input taxonomy terms and returns the fields in $data mapped to each term supplied. The idea here is to provide a semantic method for retrieving data.
When no arguments are supplied, the default is to return the fields mapped to existing terms. Using retain = '' returns all values making it equivalent to smart_obj$data
smart.data$use(
...,
subset = TRUE,
retain = NULL,
omit = NULL,
show = FALSE,
chatty = FALSE
)...Taxonomy terms as defined by self$transformation.rule: can be object names or strings
subsetA list of quoted expressions that will row-wise filter the data using data.table syntax
retain, omitA vector of strings and symbols denoting the fields to retain in the output: pattern-matching is supported
show(logical|FALSE) Should the rule be shown?
chatty(logical | TRUE) When TRUE, a confirmation dialog is invoked.
cache_mgr()$cache_mgr adds the current object to the shared "smart" cache space (see cache_layered). The shared cache is layered as 'memory' followed by 'disk.'
capture()$capture captures the current state of objects in $smart.rules and saves distinct entries as JSON objects.