Skip to contents

[Stable] Get dataset primary keys

Usage

get_keys(x, ...)

# S3 method for TealDataset
get_keys(x, ...)

# S3 method for TealDatasetConnector
get_keys(x, ...)

# S3 method for TealDataAbstract
get_keys(x, dataname, ...)

Arguments

x

an object of TealDataset or TealDatasetConnector class

...

not used, only for support of S3

dataname

(character) name of dataset to return keys for

Value

(character) vector of column names

Examples

# TealDataset --------

library(scda)
get_keys(
  dataset(
    "ADSL",
    synthetic_cdisc_data("latest")$adsl,
    keys = get_cdisc_keys("ADSL"),
    code = "ADSL <- synthetic_cdisc_data(\"latest\")$adsl"
  )
)
#> [1] "STUDYID" "USUBJID"
# TealDatasetConnector --------

library(scda)
pull_fun_adsl <- callable_function(
  function() {
    synthetic_cdisc_data("latest")$adsl
  }
)
get_keys(
  dataset_connector(
    "ADSL",
    pull_fun_adsl,
    keys = get_cdisc_keys("ADSL"),
  )
)
#> [1] "STUDYID" "USUBJID"
# TealData --------

get_keys(
  teal_data(
    dataset("x", data.frame(x1 = 1:10, y1 = 11:20), keys = "x1"),
    dataset("y", data.frame(x2 = 1:10, y2 = 11:20), keys = "x2")
  ),
  "x"
)
#> [1] "x1"