Skip to contents

[Stable] S3 method to determine if dataset is pulled (loaded).

Usage

is_pulled(x)

# S3 method for TealDatasetConnector
is_pulled(x)

# S3 method for TealDataset
is_pulled(x)

# S3 method for TealDataAbstract
is_pulled(x)

Value

(logical) TRUE if connector has been already pulled, else FALSE.

Examples

# TealDatasetConnector --------
library(magrittr)
pull_fun_adsl <- callable_function(teal.data::example_cdisc_data) %>%
  set_args(list(dataname = "ADSL"))
x <- dataset_connector("ADSL", pull_fun_adsl)

is_pulled(x)
#> [1] FALSE

load_dataset(x)
is_pulled(x)
#> [1] TRUE
# TealDataset --------
x <- dataset(
  dataname = "XY",
  x = data.frame(x = c(1, 2), y = c("a", "b"), stringsAsFactors = FALSE),
  keys = "y",
  code = "XY <- data.frame(x = c(1, 2), y = c('aa', 'bb'),
                           stringsAsFactors = FALSE)"
)

is_pulled(x)
#> [1] TRUE

library(magrittr)

# TealData --------
x1 <- dataset(
  x = teal.data::example_cdisc_data("ADSL"),
  dataname = "ADSL",
  keys = get_cdisc_keys("ADSL"),
  code = "ADSL <- teal.data::example_cdisc_data(\"ADSL\")",
  label = "ADTTE dataset"
)

x2 <- dataset(
  x = teal.data::example_cdisc_data("ADTTE"),
  dataname = "ADTTE",
  keys = get_cdisc_keys("ADTTE"),
  code = "ADTTE <- teal.data::example_cdisc_data(\"ADTTE\")",
  label = "ADTTE dataset"
)

rd <- teal_data(x1, x2)
is_pulled(rd)
#> [1] TRUE

# TealDataConnector --------
adsl_cf <- callable_function(teal.data::example_cdisc_data) %>%
  set_args(list(dataname = "ADSL"))
adsl <- cdisc_dataset_connector(
  dataname = "ADSL",
  pull_callable = adsl_cf,
  keys = get_cdisc_keys("ADSL")
)

new_cf <- callable_function(function(x) {
  x$NEW <- 1:nrow(x)
  x
})
new_cf$set_args(list(x = as.name("x")))
new <- cdisc_dataset_connector(
  dataname = "NEW",
  pull_callable = new_cf,
  keys = get_cdisc_keys("ADSL"),
  vars = list(x = adsl)
)

rdc <- cdisc_data(adsl, new)

is_pulled(rdc)
#> [1] FALSE
if (FALSE) {
load_datasets(rdc)
is_pulled(rdc)
}