In R, the paste0()
function is used to concatenate vectors after converting to character vectors.
paste0(…, collapse = NULL)
This function takes the following parameter values:
...
: This represents one or more objects to be converted to character vectors and concatenated. This is a mandatory parameter.collapse
: This is a character string used to separate the result. This is an optional parameter.This function returns a character vector of the combined values.
# code to illustrate the paste0() functionpaste0("Hi", "dear", "how", "are", "you", "today")# using a seperatorpaste0(c("Hi", "dear", "how", "are", "you", "today"), collapse = "--")
paste0()
function to concatenate the character vector.collapse
argument of the paste0()
function.