Function Dataset Connector
fun_dataset_connector.RdUsage
fun_dataset_connector(
dataname,
fun,
fun_args = NULL,
keys = character(0),
label = character(0),
code = character(0),
script = character(0),
func_name = substitute(fun),
metadata = NULL,
...
)
fun_cdisc_dataset_connector(
dataname,
fun,
fun_args = NULL,
keys = get_cdisc_keys(dataname),
parent = if (identical(dataname, "ADSL")) character(0L) else "ADSL",
label = character(0),
code = character(0),
script = character(0),
func_name = substitute(fun),
metadata = NULL,
...
)Arguments
- dataname
(
character)
A given name for the dataset it may not contain spaces- fun
(
function)
a custom function to obtain dataset.- fun_args
(
list)
additional arguments for (func).- keys
optional, (
character)
vector of dataset primary keys column names- label
(
character)
Label to describe the dataset.- code
(
character)
A character string defining code to modifyraw_datafrom this dataset. To modify current dataset code should contain at least one assignment to object defined indatanameargument. For example ifdataname = ADSLexample code should containADSL <- <some R code>. Can't be used simultaneously withscript- script
(
character)
Alternatively tocode- location of the file containing modification code. Can't be used simultaneously withscript.- func_name
(
name)
for internal purposes, please keep it default- metadata
(named
list,NULLorCallableFunction)
Field containing either the metadata about the dataset (each element of the list should be atomic and length one) or aCallableFuntionto pull the metadata from a connection. This should return alistor an object which can be converted to a list withas.list.- ...
Additional arguments applied to pull function. In case when this object code depends on the
raw_datafrom the otherTealDataset,TealDatasetConnectorobject(s) or other constant value, this/these object(s) should be included. Please note thatvarsare included to this object as localvarsand they cannot be modified within another dataset.- parent
(
character, optional) parent dataset name
Details
Create a TealDatasetConnector from function and its arguments.
Create a CDISCTealDatasetConnector from function and its arguments
with keys and parent name assigned automatically by dataname.
Examples
my_data <- function(...) {
data.frame(
ID = paste0("ABC_", seq_len(10)),
var1 = rnorm(n = 10),
var2 = rnorm(n = 10),
var3 = rnorm(n = 10)
)
}
y <- fun_dataset_connector(
dataname = "XYZ",
fun = my_data
)
y$get_code()
#> [1] "my_data <- function(...) {\n data.frame(ID = paste0(\"ABC_\", seq_len(10)), var1 = rnorm(n = 10), var2 = rnorm(n = 10), var3 = rnorm(n = 10))\n}\nXYZ <- (function(...) {\n data.frame(ID = paste0(\"ABC_\", seq_len(10)), var1 = rnorm(n = 10), var2 = rnorm(n = 10), var3 = rnorm(n = 10))\n})()"
y$pull()
get_raw_data(y)
#> ID var1 var2 var3
#> 1 ABC_1 -1.6735318 1.2566792 0.8440428
#> 2 ABC_2 0.4089891 -2.1637024 -0.4236288
#> 3 ABC_3 -0.6625774 1.5305390 -0.9308672
#> 4 ABC_4 0.6664984 -0.6452506 -0.3292875
#> 5 ABC_5 -0.6972441 -1.3088530 1.7422734
#> 6 ABC_6 -0.5080037 -0.1818499 1.4710820
#> 7 ABC_7 0.5654840 0.8386304 -0.6086874
#> 8 ABC_8 -1.1352997 1.4946240 -0.4767129
#> 9 ABC_9 0.1598120 0.5482562 -0.8371601
#> 10 ABC_10 -1.1312522 -0.7987836 -0.2869786