Function Dataset Connector
fun_dataset_connector.Rd
Usage
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_data
from this dataset. To modify current dataset code should contain at least one assignment to object defined indataname
argument. For example ifdataname = ADSL
example 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
,NULL
orCallableFunction
)
Field containing either the metadata about the dataset (each element of the list should be atomic and length one) or aCallableFuntion
to pull the metadata from a connection. This should return alist
or 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_data
from the otherTealDataset
,TealDatasetConnector
object(s) or other constant value, this/these object(s) should be included. Please note thatvars
are included to this object as localvars
and 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.7681890 1.93001016 1.7430793
#> 2 ABC_2 -0.7389704 -0.11146138 0.8467412
#> 3 ABC_3 -1.3963542 0.07890432 -0.3714166
#> 4 ABC_4 -0.9939353 0.95577089 0.8405193
#> 5 ABC_5 -1.0615356 1.47508710 -1.9871629
#> 6 ABC_6 -1.0717556 0.65685093 1.0206713
#> 7 ABC_7 -0.3082984 -0.07144519 -0.4581102
#> 8 ABC_8 0.5169985 -0.57321640 1.4439527
#> 9 ABC_9 -1.7021667 -0.25176784 -0.2921455
#> 10 ABC_10 -2.0934496 -1.10389707 1.3176479