Skip to contents

[Stable]

Universal function to pass data to teal application.

Usage

teal_data(..., join_keys = teal.data::join_keys(), code = character(0))

# S3 method for class 'teal_data'
x[names]

Arguments

...

any number of objects (presumably data objects) provided as name = value pairs.

join_keys

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

code

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

x

(teal_data)

names

(character) names of objects included in teal_subset to subset

Value

A teal_data object.

Subsetting

x[names] subsets objects in teal_data environment and limit the code to the necessary needed to build limited objects.

Examples

teal_data(x1 = iris, x2 = mtcars)
#> ✖ unverified teal_data object
#> <environment: 0x5570646f51b0> [L]
#> Parent: <environment: devtools_shims>
#> Bindings:
#>  x1: <df[,5]> [L]
#>  x2: <df[,11]> [L]


# Subsetting
data <- teal_data()
data <- eval_code(data, "a <- 1;b<-2")
data["a"]
#> ✅︎ verified teal_data object
#> <environment: 0x557067ba4f68> [L]
#> Parent: <environment: devtools_shims>
#> Bindings:
#>  a: <dbl>
data[c("a", "b")]
#> ✅︎ verified teal_data object
#> <environment: 0x5570685fd528> [L]
#> Parent: <environment: devtools_shims>
#> Bindings:
#>  b: <dbl>
#>  a: <dbl>

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]