Filter Elements in a Vetor
drop_element
- Filter to drop the matching elements of a vector.
keep_element
- Filter to keep the matching elements of a vector.
drop_element(x, pattern, regex = TRUE, ...) drop_element_regex(x, pattern, ...) drop_element_fixed(x, ...) keep_element(x, pattern, regex = TRUE, ...) keep_element_fixed(x, ...) keep_element_regex(x, pattern, ...)
x |
A character vector. |
pattern |
A regex pattern to match for exclusion. |
regex |
logical. If setting this to |
... |
Other arguments passed to |
Returns a vector with matching elements removed.
x <- c('dog', 'cat', 'bat', 'dingo', 'dragon', 'dino') drop_element(x, '^d.+?g') keep_element(x, '^d.+?g') drop_element(x, 'at$') drop_element(x, '^d') drop_element(x, '\\b(dog|cat)\\b') drop_element_fixed(x, 'bat', 'cat') drops <- c('bat', 'cat') drop_element_fixed(x, drops)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.