I have an arbitrary number of columns containing text data that have been assembled using the cbind() command, for example:
[1,] \"Text 1,1\" \"Text 1,2\" \"Te
Just use paste
with its collapse
argument:
R> row <- c("Text 1,1", "Text 1,2", "Text 1,n")
R> paste(row, collapse=" ")
[1] "Text 1,1 Text 1,2 Text 1,n"
R>
paste
is vectorised, so you can feed it multiple arguments at once.
It's easy with a data.frame,
m = matrix(letters[1:12], 3, byrow=TRUE)
do.call(paste, as.data.frame(m, stringsAsFactors=FALSE))
#[1] "a b c d" "e f g h" "i j k l"