.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,
unicode_representation = c("ascii", "latin", "character", "unicode"),
escape = 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 |
Boolean. Whether to leave a trailing comma after the last argument if
the code is multiline, some constructors allow it (e.g. |
recurse |
Boolean. Whether to recursively generate the code to construct |
implicit_names |
When data is provided, compress calls of the form |
new_line |
Boolean. Forwarded to |
one_liner |
Boolean. Whether to return a one line call. |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct strings and variable names. This makes sure that
homoglyphs (different spaces and other identically displayed unicode characters)
are printed differently, and avoid possible unfortunate copy and paste
auto conversion issues. "latin" is more lax and uses all latin characters
(code point < 256). "character" shows all characters, but not emojis. Finally
"unicode" displays all characters and emojis, which is what |
escape |
Boolean. Whether to escape double quotes and backslashes. If |
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)