paste_: Paste arguments while ignoring NAs

paste_R Documentation

Paste arguments while ignoring NAs

Description

This function behaves like base::paste(), but replaces any NA elements with an empty string. It also supports vector recycling and accepts the 'sep' and 'collapse' arguments.

Usage

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

Arguments

...

The arguments to be concatenated. These can be vectors.

sep

The string that separates the concatenated elements. Defaults to a single space.

collapse

An optional string to separate the results. NULL by default, which means no separation.

Value

A character vector of concatenated strings.

Examples

paste_("hello", NA, "you") 
# returns "hello you"

paste_(c("hello", "world"), c(NA, "everyone"), c("you", NA)) 
# returns c("hello you", "world everyone")


LukasWallrich/timesaveR documentation built on Nov. 29, 2024, 4:47 a.m.