paste several column values into one value in R

前端 未结 1 907
死守一世寂寞
死守一世寂寞 2020-12-16 07:51

I have a really simple question that I cannot find a straightforward answer for. I have a data.frame that looks like this:

df3 <- data.frame(x=c(1:10),y=c         


        
1条回答
  •  感情败类
    2020-12-16 08:24

    Yep, paste() is exactly what you want to do:

     df3$xyz <- with(df3, paste(x,y,z, sep=""))
    
     # Or, if you want the result to be numeric, rather than character
     df3$xyz <- as.numeric(with(df3, paste(x,y,z, sep="")))
    

    0 讨论(0)
提交回复
热议问题