is.flanked | R Documentation |
Checks if an element in a vector is flanked, i.e. if the elements before and after it
are %in%
a vector of candidates.
is.flanked(vec, items, edges_as_na = TRUE)
vec |
(Vector) A vector. |
items |
(Vector) A vector. |
edges_as_na |
(Logical) If |
A Logical vector of the same length as vec
.
Desi Quintans (http://www.desiquintans.com)
test_vec <- c(1, NA, 2, NA, 3, 4, NA, 5)
is.flanked(test_vec, items = c(NA), edges_as_na = TRUE)
# The edges are regarded as flanked by `NA` because `edges_as_na == TRUE` adds `NA` to
# the start and end of `vec`.
#> [1] TRUE FALSE TRUE FALSE FALSE FALSE FALSE TRUE
is.flanked(test_vec, items = c(NA), edges_as_na = FALSE)
#> [1] FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.