Concatenating N columns of text in R

前端 未结 2 394
我在风中等你
我在风中等你 2021-01-04 22:42

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

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-04 23:33

    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"
    

提交回复
热议问题