Concatenation of Elements without Separator in R Programming – paste0() Function
Last Updated :
01 Jun, 2020
paste0()
function in R Language is used to concatenate all elements without separator.
Syntax: paste0(…, collapse = NULL)
Parameters:
…: one or more R objects, to be converted to character vectors.
collapse: an optional character string to separate the results.
Example 1:
paste0( "GFG" , "gfg" )
paste0( "GFG" , " gfg" )
paste0(letters[ 1 : 4 ])
|
Output :
[1] "GFGgfg"
[1] "GFG gfg"
[1] "a" "b" "c" "d"
Example 2:
paste0(letters[ 1 : 6 ], collapse = "-" )
paste0( "G" , 1 : 5 )
|
Output:
[1] "a-b-c-d-e-f"
[1] "G1" "G2" "G3" "G4" "G5"
Share your thoughts in the comments
Please Login to comment...