In this tutorial you will learn about the R String Paste Function and its application with practical example.
R String Paste Function
In R, the paste() function is used for concatenating multiple strings in one string. The paste() function can combine any number of strings together.
Syntax:-
1 |
paste(..., sep = " ", collapse = NULL) |
Above is the general syntax of paste() function, here
…:- It represents arguments that needs to be concatenated.
sep:- It is a separator, which is used to combine arguments with. It is an optional parameter
collapse:- It is used to remove unwanted space between two string. It does not remove space between two words in a string.
Example:-
1 2 3 4 5 6 7 |
a <- "Welocome" b <- 'To' c <- "W3Adda" print(paste(a,b,c)) print(paste(a,b,c, sep = "-")) print(paste(a,b,c, sep = "", collapse = "")) |
Output:-