Learn R Programming

hacksaw (version 0.0.2)

keep_pattern: Grep, keep or discard a list or vector by pattern

Description

Grep, keep or discard a list or vector by pattern

Usage

keep_pattern(x, pattern, ...)

discard_pattern(x, pattern, ...)

Arguments

x

a list or vector.

pattern

string containing a regular expression to be matched in the given character vector.

...

additional arguments passed to grepl.

Value

A list.

Examples

Run this code
# NOT RUN {
l <- list("David", "Daniel", "Damien", "Eric", "Jared", "Zach")
l %>% keep_pattern("^D")
l %>% discard_pattern("^D")
# }

Run the code above in your browser using DataLab