Recursively applies base::as.character()
to its inputs.
Arguments
- ...
R objects to be converted to a character vector. Dynamic dots are supported.
- use_names
Whether or not to preserve names by
base::unlist()
.
See also
Other string functions:
as_comment_str()
,
as_line_feed_chr()
,
as_str()
,
capitalize_first()
,
dsv_colnames()
,
enum_str()
,
escape_lf()
,
fuse_regex()
,
prettify_nr()
,
sentenceify()
,
wrap_chr()
Examples
library(magrittr)
to_convert <-
list(tibble::tibble(a = 1:3), "A", factor("wonderful"), xfun::strict_list("day")) %T>%
print()
#> [[1]]
#> # A tibble: 3 × 1
#> a
#> <int>
#> 1 1
#> 2 2
#> 3 3
#>
#> [[2]]
#> [1] "A"
#>
#> [[3]]
#> [1] wonderful
#> Levels: wonderful
#>
#> [[4]]
#> [[1]]
#> [1] "day"
#>
#>
as.character(to_convert)
#> [1] "list(a = 1:3)" "A" "1" "list(\"day\")"
pal::as_chr(!!!to_convert)
#> [1] "1" "2" "3" "A" "wonderful" "day"