Introduction to R Programming

How to convert Vectors to Strings ?

We can convert using paste() and use collapse argument to separate vectors items

Code to convert vectors to strings

#Converting Vectors to Strings

stringVector <- c(“Introduction”, “to”, “R”)paste(stringVector, collapse = ” “)paste(stringVector, collapse = “.”)intVector <- c(1, 2, 3)paste(intVector, collapse = “,”)

Output

[1] “Introduction to R”
[1] “Introduction.to.R”
[1] “1,2,3”

Leave a Reply