R6 Class representing a dataset with its attributes
TealDataset.Rd
Any data.frame
object can be stored inside this object.
Some attributes like colnames, dimension or column names for a specific type will
be automatically derived.
Active bindings
raw_data
The data.frame behind this R6 class
data
The data.frame behind this R6 class
var_names
The column names of the data
Methods
Method new()
Create a new object of TealDataset
class
Usage
TealDataset$new(
dataname,
x,
keys = character(0),
code = character(0),
label = character(0),
vars = list(),
metadata = NULL
)
Arguments
dataname
(
character
)
A given name for the dataset it may not contain spacesx
(
data.frame
)keys
optional, (
character
)
Vector with primary keyscode
(
character
)
A character string defining the code needed to produce the data set inx
.initialize()
andrecreate()
accept code asCodeClass
which is also needed to preserve the code uniqueness and correct order.label
(
character
)
Label to describe the datasetvars
(named
list
))
In case when this object code depends on otherTealDataset
object(s) or other constant value, this/these object(s) should be included as named element(s) of the list. For example if this object code needsADSL
object we should specifyvars = list(ADSL = <adsl object>)
. It is recommended to includeTealDataset
orTealDatasetConnector
objects to thevars
list to preserve reproducibility. Please note thatvars
are included to this object as localvars
and they cannot be modified within another dataset.metadata
(named
list
orNULL
)
Field containing metadata about the dataset. Each element of the list should be atomic and of length one.
Method recreate()
Recreate this TealDataset
with its current attributes.
Usage
TealDataset$recreate(
dataname = self$get_dataname(),
x = self$get_raw_data(),
keys = self$get_keys(),
code = private$code,
label = self$get_dataset_label(),
vars = list(),
metadata = self$get_metadata()
)
Arguments
dataname
(
character
)
A given name for the dataset it may not contain spacesx
(
data.frame
)keys
optional, (
character
)
Vector with primary keyscode
(
character
)
A character string defining the code needed to produce the data set inx
.initialize()
andrecreate()
accept code asCodeClass
which is also needed to preserve the code uniqueness and correct order.label
(
character
)
Label to describe the datasetvars
(named
list
))
In case when this object code depends on otherTealDataset
object(s) or other constant value, this/these object(s) should be included as named element(s) of the list. For example if this object code needsADSL
object we should specifyvars = list(ADSL = <adsl object>)
. It is recommended to includeTealDataset
orTealDatasetConnector
objects to thevars
list to preserve reproducibility. Please note thatvars
are included to this object as localvars
and they cannot be modified within another dataset.metadata
(named
list
orNULL
)
Field containing metadata about the dataset. Each element of the list should be atomic and of length one.
Method print()
Prints this TealDataset
.
Method get_dataset()
Performs any delayed mutate calls before returning self.
Method get_attrs()
Get all dataset attributes
Method get_raw_data()
Derive the raw data frame inside this object
Method get_dataname()
Derive the name
which was formerly called dataname
Method get_dataset_label()
Derive the label
which was former called datalabel
Method get_keys()
Get primary keys of dataset
Method get_var_r6()
Get the list of dependencies that are TealDataset
or TealDatasetConnector
objects
Method reassign_datasets_vars()
Overwrites TealDataset
or TealDatasetConnector
dependencies of this TealDataset
with
those found in datasets
. Reassignment
refers only to the provided datasets
, other vars
remains the same.
Arguments
datasets
(
named list
ofTealDataset(s)
orTealDatasetConnector(s)
)
objects with valid pointers.
Details
Reassign vars
in this object to keep references up to date after deep clone.
Update is done based on the objects passed in datasets
argument.
Overwrites dependencies with names matching the names of the objects passed
in datasets
.
Examples
test_dataset <- teal.data:::TealDataset$new(
dataname = "iris",
x = iris,
vars = list(dep = teal.data:::TealDataset$new("iris2", iris))
)
test_dataset$reassign_datasets_vars(
list(iris2 = teal.data:::TealDataset$new("iris2", head(iris)))
)
Method set_keys()
Set new keys
Method set_code()
Sets reproducible code
Method get_code()
Get code to get data
Method get_code_class()
Get internal CodeClass
object
Method mutate()
Mutate dataset by code
Usage
TealDataset$mutate(code, vars = list(), force_delay = FALSE)
Method check()
Check to determine if the raw data is reproducible from the get_code()
code.
Returns
TRUE
if the dataset generated from evaluating the
get_code()
code is identical to the raw data, else FALSE
.
Method check_keys()
Check if keys has been specified correctly for dataset. Set of keys
should distinguish unique rows or be character(0)
.
Method is_pulled()
Check if dataset has already been pulled.
Examples
## ------------------------------------------------
## Method `TealDataset$reassign_datasets_vars`
## ------------------------------------------------
test_dataset <- teal.data:::TealDataset$new(
dataname = "iris",
x = iris,
vars = list(dep = teal.data:::TealDataset$new("iris2", iris))
)
test_dataset$reassign_datasets_vars(
list(iris2 = teal.data:::TealDataset$new("iris2", head(iris)))
)