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
Examples
parallelNonNA(c(1, NA, 3), c(NA, 2, NA)) # "1" "2" "3"
#> [1] 1 2 3
parallelNonNA(c(1, NA, NA), c(NA, 2, NA)) # "1" "2" ""
#> [1] 1 2 NA
## A warning is given if (non-NA) values at the same index differ
y <- parallelNonNA(c(1, 2, 3), c(1, 2, 4))
#> Warning: There are differences in parallel non-NA values (returned in attribute 'invalid')
y # "1" "2" ""
#> [1] 1 2 NA
#> attr(,"invalid")
#> index a b
#> 1 3 3 4
## attribute "invalid" contains the index and values of the differing values
attr(y, "invalid")
#> index a b
#> 1 3 3 4