As explained in this blog by Tyler Rinker:
paste
has 3 arguments.
paste (..., sep = " ", collapse = NULL)
The ...
is the stuff you want to paste together and sep and collapse are the guys to get it done. There are three basic things I paste together:
- A bunch of individual character strings.
- 2 or more strings pasted element for element.
- One string smushed together.
Here’s an example of each, though not with the correct arguments
paste("A", 1, "%")
#A bunch of individual character strings.
paste(1:4, letters[1:4])
#2 or more strings pasted element for element.
paste(1:10)
#One string smushed together. Here’s the sep/collapse rule for each:
- A bunch of individual character strings – You want sep
- 2 or more strings pasted element for element. – You want sep
- One string smushed together.- Smushin requires collapse
paste0
is short for: paste(x, sep="")
So it allows us to be lazier and more efficient.
paste0("a", "b") == paste("a", "b", sep="") ## [1] TRUE