You can use the paste() command:
You can use paste to do two things:
To concatenate values into a single "string"
example:
paste("Hey", "Everyone", sep=" ")
[1] "Hey Everyone"
The argument sep specifies the character(s) to be used between the concatenated character vectors.
Refer the example below:
z <- c("Hello", "Everyone")
z
[1] "Hello" "Everyone"
paste(z, collapse="--")
[1] "Hello--Everyone"
The argument collapse specifies the character(s) to be used between the elements of the vector to be collapsed.
You can use both sep and collapse together in a single function as follows:
paste(z, "few more text", sep="|-|", collapse="--")
[1] "Hello|-|few more text--Everyone|-|few more text"
I hope this helps!