patterns {data.table} | R Documentation |
From v1.9.6
, melt.data.table
has a new 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.
patterns
is designed purely for convenience, to be used only within the measure.vars
argument of melt.data.table
. Column names corresponding to each pattern from the data.table
is melted into a separate column.
patterns(...)
... |
A set of patterns. See example. |
melt
, https://github.com/Rdatatable/data.table/wiki/Getting-started
# makes sense only in the context of melt at the moment dt = data.table(x1 = 1:5, x2 = 6:10, y1 = letters[1:5], y2 = letters[6:10]) # melt all columns that begin with 'x' & 'y', respectively, into separate columns melt(dt, measure.vars = patterns("^x", "^y"))