paste
Concatenate Data to Make Character Data

Description

Returns a vector of character strings (the result of pasting corresponding elements of the input vectors together). If the collapse argument is used, a single string is returned.

Usage

paste(..., sep = " ", collapse = NULL, recycle0 = FALSE)
paste0(..., collapse = NULL, recycle0 = FALSE)

Arguments

... the input vectors to paste. Can be numeric, logical, complex, or character.

All arguments are coerced to mode character. Missing values (NAs) are allowed. If a name object is passed as an argument, it is coerced to a character vector of length one.

sep= the character string to be inserted between successive arguments. Can be "" for no space. The default is a single space.
collapse= NULL or a character string. If not NULL, then the vector of character strings produced by all the other arguments will be collapsed into a single character string, with the erstwhile output elements separeted by the value of collapse.
recycle0 a logical value. If FALSE zero-length ... arguments will be treated as vectors of empty character strings the length of the longest argument. If TRUE and any ... arguments have length zero, all arguments will be treated as having length zero.

Details

The i-th element of the result is the concatenation of the i-th elements of the arguments. If the length of any argument is less than the maximum, elements of that argument are repeated cyclically. For example, an argument can be a single element, to appear in each element of the result.
If collapse is given, all strings produced are finally collapsed into one long string with the collapse string inserted between elements.
paste0 is an alternate interface to paste with the sep argument removed and taken to be a blank string.
Value
If collapse is NULL, paste returns a character vector with the length equal to the maximum of the lengths of the arguments, except if recycle0 is TRUE and one argument has length zero, in which case paste returns a zero-length character vector.
If collapse is a character string, paste returns a single string.
See Also
cat, character, deparse.
Examples
paste("No.",1:3)
paste(1:3,4:6, sep="-")
paste(1:10,collapse="")
paste(1:3,4:6, sep="-", collapse="; ")
paste("No.", integer(0), recycle0=TRUE)
paste("No.", integer(0), collapse=", ", recycle0=TRUE)
Package base version 6.1.4-13
Package Index