| naCompare | R Documentation |
This function and set of operators perform simple (vectorized) comparisons using <, <=, >, >=, !=, or == between values and always returns TRUE or FALSE. TRUE only occurs if the condition can be evaluated and it is TRUE. FALSE is returned if the condition is FALSE or it cannot be evaluated.
naCompare(op, x, y)
x %<na% y
x %<=na% y
x %==na% y
x %!=na% y
x %>na% y
x %>=na% y
op |
Character, the operation to perform: |
x, y |
Vectors of numeric, character, |
Vector of logical values.
naCompare('<', c(1, 2, NA), c(10, 1, 0))
naCompare('<', c(1, 2, NA), 10)
naCompare('<', c(1, 2, NA), NA)
# compare to:
NA < 5
NA < NA
# same operations with operators:
1 %<na% 2
1 %<na% NA
3 %==na% 3
NA %==na% 3
4 %!=na% 4
4 %!=na% NA
5 %>=na% 3
5 %>=na% NA
3 %==na% c(NA, 1, 2, 3, 4)
# compare to:
1 < 2
1 < NA
3 == 3
NA == 3
4 != 4
4 != NA
5 >= 3
5 >= NA
3 == c(NA, 1, 2, 3, 4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.