Speedy/elegant way to unite many pairs of columns

后端 未结 3 1502
臣服心动
臣服心动 2021-01-25 05:00

Is there an elegant/fastR way to combine all pairs of columns in a data.frame?

For example, using mapply() and paste() we can turn this data.fr

3条回答
  •  臣服心动
    2021-01-25 05:14

    I'm not sure this is the best approach. See if the below code gives any speed improvement

    require(dplyr)
    transmute(mydf,x1=paste0( a.1,'.', a.2),x2=paste0( b.1,'.', b.2)) 
    

    Answer updated based on comment :-)

提交回复
热议问题