paste_noNA: Paste two vectors together using sep, suppressing NA (rather...

View source: R/utils.R

paste_noNAR Documentation

Paste two vectors together using sep, suppressing NA (rather than contaminating).

Description

Paste two vectors together using sep, suppressing NA (rather than contaminating).

Usage

paste_noNA(v1, v2, sep = ", ")

Arguments

v1

String (or vector of strings)

v2

String (or vector of strings)

sep

Separator (e.g., ',')

Details

Paste and str_c both appear to have a problem combining two strings when one is NA. Or alternately, when one string is NA the result should be only the first name with no sep or second component. This function does that in the case of NA.

Value

A string (or vector of strings) with v1 and v2 pasted together, avoiding NA's.

Examples

## Not run: 
paste_noNA("A",NA)
[1] "A"

## End(Not run)
## Not run: 
paste_noNA("A","B")
[1] "A, B"

## End(Not run)


steveneschrich/pgreportr documentation built on Jan. 13, 2025, 7:09 p.m.