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.33688703 1.12543265 -1.6414705
#> 2 ABC_2 0.24810936 1.95362701 -1.1255102
#> 3 ABC_3 0.23476786 -1.53438736 0.2186028
#> 4 ABC_4 -0.20140951 0.26822920 1.9893804
#> 5 ABC_5 1.06215556 -0.44386048 2.0409593
#> 6 ABC_6 -0.07160729 -0.07871559 1.1312821
#> 7 ABC_7 0.19692422 1.28469553 0.8795931
#> 8 ABC_8 1.54971803 -0.60809694 -1.2366147
#> 9 ABC_9 -0.81507071 0.38842881 -1.1633791
#> 10 ABC_10 -0.07600720 -0.88033221 -0.7064529