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" "Text 1,n"
[2,] "Text 2,1" "Text 2,2" "Text 2,n"
[3,] "Text 3,1" "Text 3,2" "Text 3,n"
[n,] "Text n,1" "Text n,2" "Text n,n"
I want to concatenate each row together, so I'm left with:
[1,] "Text 1,1 Text 1,2 Text 1,n"
[n,] "Text n,1 Text n,2 Text n,n"
Currently, I'm doing this using a for loop (where textColumns is the cbind() matrix):
concatColumn <- c()
for (i in 1:ncol(textColumns)) concatColumn <- paste(concatColumn,textColumns[,i])
Is there a simpler, more elegant way to do this in R? I've been looking around for ways to do this using the paste() command without a for loop, but haven't been able to find a solution. Thank you in advance for your help!