like {data.table}R Documentation

Convenience function for calling regexpr.

Description

Intended for use in data.table i clause 'where'.

Usage

like(vector,pattern)
vector 

Arguments

vector Either a character vector or a factor. A factor is faster (as you must have in a data.table).
pattern Passed on to regexpr.

Value

Integer vector containing the locations of vector which match the pattern using regexpr.

Note

Current implementation does not make use of sorted keys.

Author(s)

Matthew Dowle

See Also

data.table, regexpr

Examples

    DT = data.table(Name=c("Mary","George","Martha"), Salary=c(2,3,4))
    DT[Name %like% "^Mar"]   # select from DT where Name like 'Mar'

[Package data.table version 1.2 Index]