paste and paste0
In this page:
paste and paste0
paste() concatenates strings together, inserting a separator (a space by default) between each argument. paste0() is shorthand for paste(..., sep = ""), concatenating with no separator at all. Both also work element-wise on vectors, pairing up corresponding elements.
Note: paste0(a, b) is a common shortcut for building a string with no space, like a file path or identifier.
Example: paste and paste0
first <- "Hello"
second <- "World"
cat(paste(first, second), "\n")
cat(paste0(first, second), "\n")
cat(paste(first, second, sep = "-"), "\n")
Login to try C/C++/Java/PHP code in the editor
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: