patterns {data.table} R Documentation

## Obtain matching indices corresponding to patterns

### Description

patterns returns the matching indices in the argument cols corresponding to the regular expression patterns provided. The patterns must be supported by grep.

From v1.9.6, melt.data.table has an enhanced functionality in which measure.vars argument can accept a list of column names and melt them into separate columns. See the Efficient reshaping using data.tables vignette linked below to learn more.

### Usage

patterns(..., cols=character(0))


### Arguments

 ... A set of regular expression patterns. cols A character vector of names to which each pattern is matched.

DT = data.table(x1 = 1:5, x2 = 6:10, y1 = letters[1:5], y2 = letters[6:10])