Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

h2o.grep

Search for matches to an argument pattern


Description

Searches for matches to argument 'pattern' within each element of a string column.

Usage

h2o.grep(
  pattern,
  x,
  ignore.case = FALSE,
  invert = FALSE,
  output.logical = FALSE
)

Arguments

pattern

A character string containing a regular expression.

x

An H2O frame that wraps a single string column.

ignore.case

If TRUE case is ignored during matching.

invert

Identify elements that do not match the pattern.

output.logical

If TRUE returns logical vector of indicators instead of list of matching positions

Details

This function has similar semantics as R's native grep function and it supports a subset of its parameters. Default behavior is to return indices of the elements matching the pattern. Parameter 'output.logical' can be used to return a logical vector indicating if the element matches the pattern (1) or not (0).

Value

H2OFrame holding the matching positions or a logical vector if 'output.logical' is enabled.

Examples

## Not run: 
library(h2o)
h2o.init()
addresses <- as.h2o(c("2307", "Leghorn St", "Mountain View", "CA", "94043"))
zip_codes <- addresses[h2o.grep("[0-9]{5}", addresses, output.logical = TRUE),]

## End(Not run)

h2o

R Interface for the 'H2O' Scalable Machine Learning Platform

v3.32.1.2
Apache License (== 2.0)
Authors
Erin LeDell [aut, cre], Navdeep Gill [aut], Spencer Aiello [aut], Anqi Fu [aut], Arno Candel [aut], Cliff Click [aut], Tom Kraljevic [aut], Tomas Nykodym [aut], Patrick Aboyoun [aut], Michal Kurka [aut], Michal Malohlava [aut], Ludi Rehak [ctb], Eric Eckstrand [ctb], Brandon Hill [ctb], Sebastian Vidrio [ctb], Surekha Jadhawani [ctb], Amy Wang [ctb], Raymond Peck [ctb], Wendy Wong [ctb], Jan Gorecki [ctb], Matt Dowle [ctb], Yuan Tang [ctb], Lauren DiPerna [ctb], Tomas Fryda [ctb], H2O.ai [cph, fnd]
Initial release
2021-04-29

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.