#Create vector
vec <- c("A", "C", "G", "T")
#Flatten vector
vec |> stringr::str_flatten()[1] "ACGT"
The function stringr::str_flatten() allows you to create a single string from a character vector.
By default str_flatten() will add no spaces/separators when flattening.
[1] "ACGT"
You can pipe the output for str_c() to str_flatten().
The individual vector elements can be separated in the out string with the collapse= option.
[1] "A,C,G,T"
You can specify a final separator with last =. Additionally, separators can contain as many characters as you would like.