.cstr_apply {constructive} | R Documentation |
.cstr_apply
Description
Exported for custom constructor design. If recurse
is TRUE
(default), we
recurse to construct args
and insert their construction code in a fun(...)
call returned
as a character vector. If args
already contains code rather than object to
construct one should set recurse
to FALSE
.
Usage
.cstr_apply(
args,
fun = "list",
...,
trailing_comma = FALSE,
recurse = TRUE,
implicit_names = FALSE,
new_line = TRUE,
one_liner = FALSE
)
Arguments
args |
A list of arguments to construct recursively, or code if |
fun |
The function name to use to build code of the form "fun(...)" |
... |
options passed recursively to the further methods |
trailing_comma |
leave a trailing comma after the last argument if
the code is multiline, some constructors allow it (e.g. |
recurse |
Whether to recursively generate the code to construct |
implicit_names |
When data is provided, compress calls of the form |
new_line |
passed to wrap to remove add a line after "fun(" and before ")", forced to
|
one_liner |
Whether to return a one line call. |
Value
A character vector of code
Examples
a <- 1
.cstr_apply(list(a=a), "foo")
.cstr_apply(list(a=a), "foo", data = list(a=1))
.cstr_apply(list(a=a), "foo", data = list(a=1), implicit_names = TRUE)
.cstr_apply(list(b=a), "foo", data = list(a=1), implicit_names = TRUE)
.cstr_apply(list(a="c(1,2)"), "foo")
.cstr_apply(list(a="c(1,2)"), "foo", recurse = FALSE)