Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个非常简单的问题,我找不到直接的答案。我有一个如下所示的 data.frame:
df3 <- data.frame(x=c(1:10),y=c(5:14),z=c(25:34)) ID x y z 1 1 5 25 2 2 6 26 3 3 7 27 etc.
我想将每列中的不同值“粘贴”在一起,以便它们形成一个单一的组合值,如:
ID x+y+z 1 1525 2 2626 3 3727
我确信这很容易做到,但我就是不知道怎么做!
paste()是的,这正是您想要做的:
paste()
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="")))