Store values neatly in an Excel or other dataframe for summary or record-keeping, but is in a format that can be readily parsed back to an expression if need be. This is important in cases where the names of columns want to be saved for a dataframe in a particular script to reference back or to QA later on. The string can be converted back to a vector by its counterpart function string_to_vector() in this package.

vctr_to_str(vector, quote = "'", collapse = ", ")

Examples

# String to Vector test_vctr <- "c('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J')" str_to_vctr(test_vctr)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
test_vctr <- 'c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")' str_to_vctr(test_vctr)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
test_vctr <- 'c(\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\")' str_to_vctr(test_vctr)
#> [1] "A" "B" "C" "D" "E" "F" "G" "H" "I" "J"
# Vector to String vctr_to_str(LETTERS[1:5])
#> [1] "c('A', 'B', 'C', 'D', 'E')"
vctr_to_str(LETTERS[1:5], quote = "\"")
#> [1] "c(\"A\", \"B\", \"C\", \"D\", \"E\")"