View source: R/combine_logic.R
| combine_logic | R Documentation |
A utility function to combine two or more logical vectors using
logical AND (&) or OR (|) operations. Supports NA handling and
checks for consistent vector lengths.
combine_logic(..., op = "&", na.rm = FALSE)
... |
Logical vectors to combine. |
op |
Operator to apply: |
na.rm |
Logical. If TRUE, treats NA values as TRUE (default is FALSE). |
A single logical vector of the same length as inputs.
x <- 1:5
combine_logic(x > 2, x %% 2 == 1) # AND by default
combine_logic(x > 2, x %% 2 == 1, op = "|") # OR logic
combine_logic(c(TRUE, NA), c(TRUE, TRUE), na.rm = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.