-2

I have a vector for example test<-c("red","blue","green"). How can i join the elements of the vector into one so i have test<-c("red/blue/green").

I know I could use paste(test[1],test[2],test[3], sep="/") but that's too much work because my vector has hundreds of elements!

thx for your help!

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239

1 Answers1

7

You can use collapse parameter of paste

> paste(test , collapse ="/")
[1] "red/blue/green"
CHP
  • 16,981
  • 4
  • 38
  • 57