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 -0.032676972 0.21588437 -0.9391613643
#> 2 ABC_2 0.411655084 0.67313442 0.0319632157
#> 3 ABC_3 0.193977615 1.11271616 -0.0002405162
#> 4 ABC_4 -0.444570514 -0.87239222 1.5164193245
#> 5 ABC_5 1.353029775 0.06697122 -1.6248678117
#> 6 ABC_6 0.638432931 1.39706272 1.8336694243
#> 7 ABC_7 -0.205454953 -1.71643418 -0.4126614055
#> 8 ABC_8 0.518839695 -0.87728148 -0.4265393934
#> 9 ABC_9 -0.295747015 -0.57439082 -0.1603393002
#> 10 ABC_10 0.004489559 1.27482966 -0.4989139929