Create a character vector from a string with quotation marks
Source:R/unpaste_unquote.R
unpaste_unquote.RdCreate a character vector from a string with quotation marks
Arguments
- x
- collapse
character vector with elements that were used to collapse values when
xwas created, and are now used to splitxon. Can becharacter(0)to leavexas a character string.- quotemarks
character vector with quotation marks to be removed from
x. Can becharacter(0)to not remove any quotation marks.
Details
unpaste_unquote() is not the exact reverse of paste_quoted(): it does
not restore zero-length elements to their original value, e.g., "'NULL'"
to NULL, or "'character(0)'" to character(0).
See also
paste_quoted() for the approximate opposite of unpaste_unquote().
Other functions to modify character vectors:
as.numeric_safe(),
reexports,
replace_vals(),
signal_text(),
vect_to_char(),
wrap_text()
Examples
x <- paste_quoted(c("ff", "gG", "HH"))
x
#> [1] "'ff', 'gG', 'HH'"
unpaste_unquote(x = x, collapse = ", ", quotemarks = "'")
#> [1] "ff" "gG" "HH"
unpaste_unquote(x = x, collapse = ", ", quotemarks = "\"")
#> [1] "'ff'" "'gG'" "'HH'"
unpaste_unquote(x = x, collapse = character(0), quotemarks = c("'", "\""))
#> [1] "ff, gG, HH"
unpaste_unquote(x = x, collapse = character(0), quotemarks = character(0))
#> [1] "'ff', 'gG', 'HH'"