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.
例如,我有一个向量test<-c("red","blue","green")。我怎样才能将向量的元素合二为一,这样我就有了test<-c("red/blue/green")。
test<-c("red","blue","green")
test<-c("red/blue/green")
我知道我可以使用paste(test[1],test[2],test[3], sep="/"),但工作量太大,因为我的向量有数百个元素!
paste(test[1],test[2],test[3], sep="/")
谢谢你的帮助!
您可以使用collapse参数paste
collapse
paste
> paste(test , collapse ="/") [1] "red/blue/green"