Skip to contents

Create a character vector from a string with quotation marks

Usage

unpaste_unquote(x, collapse = c(", ", "; "), quotemarks = c("'", "\""))

Arguments

x

a character string.

collapse

character vector with elements that were used to collapse values when x was created, and are now used to split x on. Can be character(0) to leave x as a character string.

quotemarks

character vector with quotation marks to be removed from x. Can be character(0) to not remove any quotation marks.

Value

x without the quotation marks in quotemarks, split into a vector on the string in collapse.

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'"