Retrieve raw data
get_raw_data.Rd
Usage
get_raw_data(x, dataname = NULL)
# S3 method for TealDataset
get_raw_data(x, dataname = NULL)
# S3 method for TealDatasetConnector
get_raw_data(x, dataname = NULL)
# S3 method for TealDataAbstract
get_raw_data(x, dataname = NULL)
Arguments
- x
(
TealDataset
,TealDatasetConnector
,TealDataAbstract
)
object- dataname
(
character
)
Name of dataset to return raw data for.
Value
data.frame
with the raw data inserted into the R6 objects. In case of
TealDataAbstract
, list
of data.frame
can be returned
if user doesn't specify dataname
- (get_raw_data
from all datasets).
Examples
# TealDataset ---------
library(scda)
ADSL <- synthetic_cdisc_data("latest")$adsl
x <- dataset(dataname = "ADSL", x = ADSL)
get_raw_data(x)
#> # A tibble: 400 × 56
#> STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL
#> <chr> <chr> <chr> <chr> <int> <fct> <fct> <fct> <fct> <fct> <fct>
#> 1 AB12345 AB12345-C… id-128 CHN-3 32 YEARS M ASIAN HISPA… CHN Y
#> 2 AB12345 AB12345-C… id-262 CHN-15 35 YEARS M BLAC… NOT H… CHN N
#> 3 AB12345 AB12345-R… id-378 RUS-3 30 YEARS F ASIAN NOT H… RUS N
#> 4 AB12345 AB12345-C… id-220 CHN-11 26 YEARS F ASIAN NOT H… CHN N
#> 5 AB12345 AB12345-C… id-267 CHN-7 40 YEARS M ASIAN NOT H… CHN N
#> 6 AB12345 AB12345-C… id-201 CHN-15 49 YEARS M ASIAN NOT H… CHN Y
#> 7 AB12345 AB12345-U… id-45 USA-1 34 YEARS F ASIAN NOT H… USA N
#> 8 AB12345 AB12345-U… id-261 USA-1 32 YEARS F ASIAN NOT H… USA N
#> 9 AB12345 AB12345-N… id-173 NGA-11 24 YEARS F BLAC… NOT H… NGA N
#> 10 AB12345 AB12345-C… id-307 CHN-1 24 YEARS M ASIAN NOT H… CHN Y
#> # … with 390 more rows, and 45 more variables: INVID <chr>, INVNAM <chr>,
#> # ARM <fct>, ARMCD <fct>, ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>,
#> # TRT01A <fct>, TRT02P <fct>, TRT02A <fct>, REGION1 <fct>, STRATA1 <fct>,
#> # STRATA2 <fct>, BMRKR1 <dbl>, BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>,
#> # BMEASIFL <fct>, BEP01FL <fct>, AEWITHFL <fct>, RANDDT <date>,
#> # TRTSDTM <dttm>, TRTEDTM <dttm>, TRT01SDTM <dttm>, TRT01EDTM <dttm>,
#> # TRT02SDTM <dttm>, TRT02EDTM <dttm>, AP01SDTM <dttm>, AP01EDTM <dttm>, …
# TealDatasetConnector ---------
library(scda)
pull_fun_adsl <- callable_function(
function() {
synthetic_cdisc_data("latest")$adsl
}
)
dc <- dataset_connector("ADSL", pull_fun_adsl)
load_dataset(dc)
get_raw_data(dc)
#> # A tibble: 400 × 56
#> STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL
#> <chr> <chr> <chr> <chr> <int> <fct> <fct> <fct> <fct> <fct> <fct>
#> 1 AB12345 AB12345-C… id-128 CHN-3 32 YEARS M ASIAN HISPA… CHN Y
#> 2 AB12345 AB12345-C… id-262 CHN-15 35 YEARS M BLAC… NOT H… CHN N
#> 3 AB12345 AB12345-R… id-378 RUS-3 30 YEARS F ASIAN NOT H… RUS N
#> 4 AB12345 AB12345-C… id-220 CHN-11 26 YEARS F ASIAN NOT H… CHN N
#> 5 AB12345 AB12345-C… id-267 CHN-7 40 YEARS M ASIAN NOT H… CHN N
#> 6 AB12345 AB12345-C… id-201 CHN-15 49 YEARS M ASIAN NOT H… CHN Y
#> 7 AB12345 AB12345-U… id-45 USA-1 34 YEARS F ASIAN NOT H… USA N
#> 8 AB12345 AB12345-U… id-261 USA-1 32 YEARS F ASIAN NOT H… USA N
#> 9 AB12345 AB12345-N… id-173 NGA-11 24 YEARS F BLAC… NOT H… NGA N
#> 10 AB12345 AB12345-C… id-307 CHN-1 24 YEARS M ASIAN NOT H… CHN Y
#> # … with 390 more rows, and 45 more variables: INVID <chr>, INVNAM <chr>,
#> # ARM <fct>, ARMCD <fct>, ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>,
#> # TRT01A <fct>, TRT02P <fct>, TRT02A <fct>, REGION1 <fct>, STRATA1 <fct>,
#> # STRATA2 <fct>, BMRKR1 <dbl>, BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>,
#> # BMEASIFL <fct>, BEP01FL <fct>, AEWITHFL <fct>, RANDDT <date>,
#> # TRTSDTM <dttm>, TRTEDTM <dttm>, TRT01SDTM <dttm>, TRT01EDTM <dttm>,
#> # TRT02SDTM <dttm>, TRT02EDTM <dttm>, AP01SDTM <dttm>, AP01EDTM <dttm>, …
# TealData ----------------
library(scda)
latest_data <- synthetic_cdisc_data("latest")
adsl <- cdisc_dataset(
dataname = "ADSL",
x = latest_data$adsl,
code = "library(scda)\nADSL <- synthetic_cdisc_data(\"latest\")$adsl"
)
adtte <- cdisc_dataset(
dataname = "ADTTE",
x = latest_data$adtte,
code = "library(scda)\nADTTE <- synthetic_cdisc_data(\"latest\")$adtte"
)
rd <- teal.data:::TealData$new(adsl, adtte)
get_raw_data(rd)
#> $ADSL
#> # A tibble: 400 × 56
#> STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL
#> <chr> <chr> <chr> <chr> <int> <fct> <fct> <fct> <fct> <fct> <fct>
#> 1 AB12345 AB12345-C… id-128 CHN-3 32 YEARS M ASIAN HISPA… CHN Y
#> 2 AB12345 AB12345-C… id-262 CHN-15 35 YEARS M BLAC… NOT H… CHN N
#> 3 AB12345 AB12345-R… id-378 RUS-3 30 YEARS F ASIAN NOT H… RUS N
#> 4 AB12345 AB12345-C… id-220 CHN-11 26 YEARS F ASIAN NOT H… CHN N
#> 5 AB12345 AB12345-C… id-267 CHN-7 40 YEARS M ASIAN NOT H… CHN N
#> 6 AB12345 AB12345-C… id-201 CHN-15 49 YEARS M ASIAN NOT H… CHN Y
#> 7 AB12345 AB12345-U… id-45 USA-1 34 YEARS F ASIAN NOT H… USA N
#> 8 AB12345 AB12345-U… id-261 USA-1 32 YEARS F ASIAN NOT H… USA N
#> 9 AB12345 AB12345-N… id-173 NGA-11 24 YEARS F BLAC… NOT H… NGA N
#> 10 AB12345 AB12345-C… id-307 CHN-1 24 YEARS M ASIAN NOT H… CHN Y
#> # … with 390 more rows, and 45 more variables: INVID <chr>, INVNAM <chr>,
#> # ARM <fct>, ARMCD <fct>, ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>,
#> # TRT01A <fct>, TRT02P <fct>, TRT02A <fct>, REGION1 <fct>, STRATA1 <fct>,
#> # STRATA2 <fct>, BMRKR1 <dbl>, BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>,
#> # BMEASIFL <fct>, BEP01FL <fct>, AEWITHFL <fct>, RANDDT <date>,
#> # TRTSDTM <dttm>, TRTEDTM <dttm>, TRT01SDTM <dttm>, TRT01EDTM <dttm>,
#> # TRT02SDTM <dttm>, TRT02EDTM <dttm>, AP01SDTM <dttm>, AP01EDTM <dttm>, …
#>
#> $ADTTE
#> # A tibble: 2,000 × 68
#> STUDYID USUBJID SUBJID SITEID AGE AGEU SEX RACE ETHNIC COUNTRY DTHFL
#> <chr> <chr> <chr> <chr> <int> <fct> <fct> <fct> <fct> <fct> <fct>
#> 1 AB12345 AB12345-B… id-105 BRA-1 38 YEARS M BLAC… HISPA… BRA N
#> 2 AB12345 AB12345-B… id-105 BRA-1 38 YEARS M BLAC… HISPA… BRA N
#> 3 AB12345 AB12345-B… id-105 BRA-1 38 YEARS M BLAC… HISPA… BRA N
#> 4 AB12345 AB12345-B… id-105 BRA-1 38 YEARS M BLAC… HISPA… BRA N
#> 5 AB12345 AB12345-B… id-105 BRA-1 38 YEARS M BLAC… HISPA… BRA N
#> 6 AB12345 AB12345-B… id-134 BRA-1 47 YEARS M WHITE NOT H… BRA Y
#> 7 AB12345 AB12345-B… id-134 BRA-1 47 YEARS M WHITE NOT H… BRA Y
#> 8 AB12345 AB12345-B… id-134 BRA-1 47 YEARS M WHITE NOT H… BRA Y
#> 9 AB12345 AB12345-B… id-134 BRA-1 47 YEARS M WHITE NOT H… BRA Y
#> 10 AB12345 AB12345-B… id-134 BRA-1 47 YEARS M WHITE NOT H… BRA Y
#> # … with 1,990 more rows, and 57 more variables: INVID <chr>, INVNAM <chr>,
#> # ARM <fct>, ARMCD <fct>, ACTARM <fct>, ACTARMCD <fct>, TRT01P <fct>,
#> # TRT01A <fct>, TRT02P <fct>, TRT02A <fct>, REGION1 <fct>, STRATA1 <fct>,
#> # STRATA2 <fct>, BMRKR1 <dbl>, BMRKR2 <fct>, ITTFL <fct>, SAFFL <fct>,
#> # BMEASIFL <fct>, BEP01FL <fct>, AEWITHFL <fct>, RANDDT <date>,
#> # TRTSDTM <dttm>, TRTEDTM <dttm>, TRT01SDTM <dttm>, TRT01EDTM <dttm>,
#> # TRT02SDTM <dttm>, TRT02EDTM <dttm>, AP01SDTM <dttm>, AP01EDTM <dttm>, …
#>
# TealDataConnector --------
library(scda)
adsl <- scda_cdisc_dataset_connector(dataname = "ADSL", "adsl")
adlb <- scda_cdisc_dataset_connector(dataname = "ADLB", "adlb")
open_fun <- callable_function(library)
open_fun$set_args(list(package = "scda"))
con <- data_connection(open_fun = open_fun)
con$set_open_server(
function(id, connection) {
moduleServer(
id = id,
module = function(input, output, session) {
connection$open(try = TRUE)
return(invisible(connection))
}
)
}
)
rdc <- relational_data_connector(connection = con, connectors = list(adsl, adlb))
rdc$set_ui(
function(id, connection, connectors) {
ns <- NS(id)
tagList(
connection$get_open_ui(ns("open_connection")),
textInput(ns("name"), p("Choose", code("scda data version")), value = "latest"),
do.call(
what = "tagList",
args = lapply(
connectors,
function(connector) {
div(
connector$get_ui(
id = ns(connector$get_dataname())
),
br()
)
}
)
)
)
}
)
rdc$set_server(
function(id, connection, connectors) {
moduleServer(
id = id,
module = function(input, output, session) {
# opens connection
connection$get_open_server()(id = "open_connection", connection = connection)
if (connection$is_opened()) {
for (connector in connectors) {
set_args(connector, args = list(name = input$name))
# pull each dataset
connector$get_server()(id = connector$get_dataname())
if (connector$is_failed()) {
break
}
}
}
}
)
}
)
if (FALSE) {
load_datasets(rdc)
get_raw_data(rdc)
}
# TealData (with connectors) --------
drc <- cdisc_data(rdc)
if (FALSE) {
get_raw_data(drc)
}