parallelNonNA | R Documentation |
two vectors a and b of same length are merged in such a way that at index i the result vector contains (1) a[i] if a[i] is not NA and b[i] is NA or b[i] == a[i], (2) b[i] if b[i] is not NA and a[i] is NA or a[i] == b[i], (3) "" if a[i] is not NA and b[i] is not NA and a[i] != b[i] or if both a[i] and b[i] are NA
parallelNonNA(a, b)
a |
vector 1 |
b |
vector 2 |
character vector of same length as a and b
parallelNonNA(c(1, NA, 3), c(NA, 2, NA)) # "1" "2" "3"
parallelNonNA(c(1, NA, NA), c(NA, 2, NA)) # "1" "2" ""
## A warning is given if (non-NA) values at the same index differ
y <- parallelNonNA(c(1, 2, 3), c(1, 2, 4))
y # "1" "2" ""
## attribute "invalid" contains the index and values of the differing values
attr(y, "invalid")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.