Description Usage Arguments Value Examples
drop_element
- Filter to drop the matching elements of a vector.
keep_element
- Filter to keep the matching elements of a vector.
1 2 3 4 5 6 7 8 9 10 11 | 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.
1 2 3 4 5 6 7 8 9 10 | 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)
|
[1] "cat" "bat" "dino"
[1] "dog" "dingo" "dragon"
[1] "dog" "dingo" "dragon" "dino"
[1] "cat" "bat"
[1] "bat" "dingo" "dragon" "dino"
[1] "dog" "dingo" "dragon" "dino"
[1] "dog" "dingo" "dragon" "dino"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.