paste_noNA | R Documentation |
Paste two vectors together using sep, suppressing NA (rather than contaminating).
paste_noNA(v1, v2, sep = ", ")
v1 |
String (or vector of strings) |
v2 |
String (or vector of strings) |
sep |
Separator (e.g., ',') |
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.
A string (or vector of strings) with v1 and v2 pasted together, avoiding NA's.
## Not run:
paste_noNA("A",NA)
[1] "A"
## End(Not run)
## Not run:
paste_noNA("A","B")
[1] "A, B"
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.