opts_atomic {constructive} | R Documentation |
Constructive options for atomic types
Description
These options will be used on atomic types ("logical", "integer", "numeric", "complex", "character" and "raw").
They can also be directly provided to atomic types through their own opts_*()
function, and in this case the latter will have precedence.
Usage
opts_atomic(
...,
trim = NULL,
fill = c("default", "rlang", "+", "...", "none"),
compress = TRUE
)
Arguments
... |
Additional options used by user defined constructors through the |
trim |
|
fill |
String. Method to use to represent the trimmed elements. |
compress |
Boolean. If |
Details
If trim
is provided, depending on fill
we will present trimmed elements as followed:
-
"default"
: Use default atomic constructors, so for instancec("a", "b", "c")
might becomec("a", character(2))
. -
"rlang"
: Use rlang atomic constructors, so for instancec("a", "b", "c")
might becomec("a", rlang::new_character(2))
, theserlang
constructors create vectors ofNAs
, so it's different from the default option. -
"+"
: Use unary+
, so for instancec("a", "b", "c")
might becomec("a", +2)
. -
"..."
: Use...
, so for instancec("a", "b", "c")
might becomec("a", ...)
-
"none"
: Don't represent trimmed elements.
Depending on the case some or all of the choices above might generate code that cannot be executed. The 2 former options above are the most likely to succeed and produce an output of the same type and dimensions recursively. This would at least be the case for data frame.
Value
An object of class <constructive_options/constructive_options_atomic>
Examples
construct(iris, opts_atomic(trim = 2), check = FALSE) # fill = "default"
construct(iris, opts_atomic(trim = 2, fill = "rlang"), check = FALSE)
construct(iris, opts_atomic(trim = 2, fill = "+"), check = FALSE)
construct(iris, opts_atomic(trim = 2, fill = "..."), check = FALSE)
construct(iris, opts_atomic(trim = 2, fill = "none"), check = FALSE)
construct(iris, opts_atomic(trim = 2, fill = "none"), check = FALSE)
x <- c("a a", "a\U000000A0a", "a\U00002002a", "\U430 \U430")
construct(x, opts_atomic(unicode_representation = "unicode"))
construct(x, opts_atomic(unicode_representation = "character"))
construct(x, opts_atomic(unicode_representation = "latin"))
construct(x, opts_atomic(unicode_representation = "ascii"))