An augmented version of base::paste()
with options
to manage `NA` values.
Usage
paste(..., sep = " ", collapse = NULL, na.rm = FALSE)
paste0(..., collapse = NULL, na.rm = FALSE)
Arguments
- ...
R objects to be converted to character vectors.
- sep
A character. A string to separate the terms.
- collapse
A character. An string to separate the results.
- na.rm
A logical. Whether to remove NA values from 'x'.
Examples
# Base paste() NA handling behavior
paste(
'The', c('red', NA_character_, 'orange'), 'fox jumped', NA_character_, 'over the fence.',
collapse = ' '
)
#> [1] "The red fox jumped NA over the fence. The NA fox jumped NA over the fence. The orange fox jumped NA over the fence."
# Removal of NA values
paste(
'The', c('red', NA_character_, 'orange'), 'fox jumped', NA_character_, 'over the fence.',
collapse = ' ',
na.rm = TRUE
)
#> [1] "The red fox jumped over the fence. The orange fox jumped over the fence."