paste {base}R Documentation

Concatenate Strings


Concatenate vectors after converting to character.


paste(..., sep = " ", collapse = NULL)


... one or more R objects, to be converted to character vectors.
sep a character string to separate the terms.
collapse an optional character string to separate the results.


paste converts its arguments (via as.character) to character strings, and concatenates them (separating them by the string given by sep). If the arguments are vectors, they are concatenated term-by-term to give a character vector result. Vector arguments are recycled as needed, with zero-length arguments being recycled to "".

If a value is specified for collapse, the values in the result are then concatenated into a single string, with the elements being separated by the value of collapse.


A character vector of the concatenated values. This will be of length zero if all the objects are, unless collapse is non-NULL, in which case it is a single empty string.


Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

String manipulation with as.character, substr, nchar, strsplit; further, cat which concatenates and writes to a file, and sprintf for C like string construction.


paste(1:12) # same as as.character(1:12)
paste("A", 1:6, sep = "")
paste("Today is", date())

[Package base version 2.5.0 Index]