teal applicationsR/teal_data-constructor.R, R/teal_data-extract.R
teal_data.RdInitializes a data for teal application.
any number of objects (presumably data objects) provided as name = value pairs.
(join_keys or single join_key_set)
optional object with datasets column names used for joining.
If empty then no joins between pairs of objects.
(character, language) optional code to reproduce the datasets provided in ....
Note this code is not executed and the teal_data may not be reproducible
Use verify() to verify code reproducibility.
(teal_data)
(character) names of objects included in teal_subset to subset
A teal_data object.
A teal_data is meant to be used for reproducibility purposes. The class inherits from
teal.code::qenv and we encourage to get familiar with teal.code first.
teal_data has following characteristics:
It inherits from the environment and methods such as $, get(), ls(), as.list(),
parent.env() work out of the box.
teal_data is a locked environment, and data modification is only possible through the
teal.code::eval_code() and within.qenv() functions.
It stores metadata about the code used to create the data (see get_code()).
It supports slicing (see teal.code::subset-qenv)
Is immutable which means that each code evaluation does not modify the original teal_data
environment directly.
It maintains information about relationships between datasets (see join_keys()).
x[names] subsets objects in teal_data environment and limit the code to the necessary needed to build limited
objects.
teal_data(x1 = iris, x2 = mtcars)
#> ✖ code unverified
#> <environment: 0x55d900b29b20> 🔒
#> Parent: <environment: package:teal.data>
#> Bindings:
#> - x1: [data.frame]
#> - x2: [data.frame]
# Subsetting
data <- teal_data()
data <- eval_code(data, "a <- 1;b<-2")
data["a"]
#> ✅︎ code verified
#> <environment: 0x55d904538d30> 🔒
#> Parent: <environment: package:teal.data>
#> Bindings:
#> - a: [numeric]
data[c("a", "b")]
#> ✅︎ code verified
#> <environment: 0x55d9044bc220> 🔒
#> Parent: <environment: package:teal.data>
#> Bindings:
#> - a: [numeric]
#> - b: [numeric]
join_keys(data) <- join_keys(join_key("a", "b", "x"))
join_keys(data["a"]) # should show empty keys
#> An empty join_keys object.
join_keys(data["b"])
#> A join_keys object containing foreign keys between 2 datasets:
#> a: [no primary keys]
#> <-- b: [x]
#> b: [no primary keys]
#> --> a: [x]
join_keys(data)["a"] # should show empty keys
#> An empty join_keys object.
join_keys(data)["b"]
#> A join_keys object containing foreign keys between 2 datasets:
#> a: [no primary keys]
#> <-- b: [x]
#> b: [no primary keys]
#> --> a: [x]