like: Pattern matching using wildcards

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Pattern matching using wildcards

Usage

1
x %like% pattern

Arguments

pattern

character string containing the pattern to be matched

x

values to be matched

Details

Only wildcards matching a single character '?' or zero or more characters '*' are allowed. Matches are case-insensitive. The pattern is first converted to a regular expression using glob2rx then matched to values in x using grep.

This is a shortcut for a commonly used expression found in the subset example where nm %in% grep("^M", nm, value=TRUE) simplifies to nm %like% 'M*'.

Value

A logical vector indicating if there is a match or not. This will mostly be useful in conjunction with the subset function.

Author(s)

Chris Stubben

See Also

grep, glob2rx, subset

Examples

1
2
3
4
data(proks)
subset(proks, name %like% 'Yersinia*', c(name, released))
# also works with date or numeric fields
subset(proks, released %like% '2008-01*', c(name, released))

cstubben/genomes2 documentation built on May 14, 2019, 12:25 p.m.