> paste("good", "job")
[1] "good job"
> paste("good", "job", sep=" - ")
[1] "good - job"
> paste(letters[1:4])
[1] "a" "b" "c" "d"
> paste(letters[1:4],collapse=",")
[1] "a,b,c,d"
The arguments can be vectors. If one is shorter than the other, the shorter one will be used repeatly.
> paste("G",1:4,sep="")
[1] "G1" "G2" "G3" "G4"
> paste0("G",1:4) #same result
[1] "G1" "G2" "G3" "G4"
Join multiple vectors:
> paste("G",1:4,letters[1:4],sep="_")
[1] "G_1_a" "G_2_b" "G_3_c" "G_4_d"
> paste("G",1:4,letters[1:4],sep="_", collapse=" > ")
[1] "G_1_a > G_2_b > G_3_c > G_4_d"