Learn R Programming

utile.tools (version 0.3.0)

paste: Concatenate strings

Description

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)

Value

Character vector of concatenated values.

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'.

See Also

Examples

Run this code
# Base paste() NA handling behavior
paste(
  'The', c('red', NA_character_, 'orange'), 'fox jumped', NA_character_, 'over the fence.',
  collapse = ' '
)

# Removal of NA values
paste(
  'The', c('red', NA_character_, 'orange'), 'fox jumped', NA_character_, 'over the fence.',
  collapse = ' ',
  na.rm = TRUE
)

Run the code above in your browser using DataLab