Learn R Programming

Kmisc (version 0.5.0)

lg: length( grep( ... ) )

Description

This is a wrapper to a length( grep( ... ) ). See examples for usage. Primarily intended for interactive, not programmatic, use.

Usage

lg(pattern, x, perl = TRUE, ...)

Arguments

pattern
regex pattern passed to grep.
x
a vector on which we attempt to match pattern on.
perl
boolean. use perl-compatible regular expressions?
...
additional arguments passed to grep.

See Also

re_exists

Examples

Run this code
x <- c("apple", "banana", "cherry")
if( lg( "^ap", x ) > 0 ) {
  print( "regular expression '^ap' found in 'x'" )
  }

Run the code above in your browser using DataLab