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")
Usage
opts_atomic(
...,
trim = NULL,
fill = c("default", "rlang", "+", "...", "none"),
compress = TRUE,
unicode_representation = c("ascii", "latin", "character", "unicode"),
escape = FALSE
)
Arguments
... |
Should not be used. Forces passing arguments by name. |
trim |
|
fill |
String. Method to use to represent the trimmed elements. |
compress |
Boolean. It |
unicode_representation |
By default "ascii", which means only ASCII characters
(code point < 128) will be used to construct a string. 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 |
Whether to escape double quotes and backslashes. 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 suceed 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"))