collapseHumdrum allows you collapse a data field across
across groups within the data indicated by the by argument.
Data is "collapsed" either by pasting the data into a string,
or by putting them into list.
collapseStops, collapsePaths, and collapseRecords are built-in
calls to collapseHumtab, with some additional optimizations.
Usage
collapseHumdrum(
humdrumR,
by,
fields = selectedFields(humdrumR),
dataTypes = "GLIMDd",
collapseAtomic = TRUE,
sep = " "
)
collapseStops(
humdrumR,
fields = selectedFields(humdrumR),
collapseAtomic = TRUE,
sep = " "
)
collapsePaths(
humdrumR,
fields = selectedFields(humdrumR),
collapseAtomic = TRUE,
sep = " "
)
collapseRecords(
humdrumR,
fields = selectedFields(humdrumR),
collapseAtomic = TRUE,
sep = " "
)Arguments
- humdrumR
HumdrumR data.
Must be a humdrumR data object.
- by
Fields to collapse data within.
Must be
character.Must be
characterstrings partially matching the name(s) of a field(s) in thehumdrumRinput.Data in the
fieldswill be collapsed within these fields.- fields
The target field(s) in the
humdrumRdata to collapse.Defaults to
selectedFields(humdrumR).Must be
characterstrings partially matching the name(s) of a data field(s) in thehumdrumRinput.- dataTypes
Which types of humdrum record(s) to collapse.
Defaults to
"GLIMDd".Must be
character. Legal values are'G', 'L', 'I', 'M', 'D', 'd'or any combination of these (e.g.,"LIM"). (See the humdrum table documentation Fields section for explanation.)- collapseAtomic
Whether to collapse the data into
characterstrings.Defaults to
TRUE.Must be a singleton
logicalvalue: an on/off switch.If
TRUE, data is collapsed into a singlecharacterstring. IfFALSE, data is conctanated in alist.- sep
A separator for collapsed strings.
Defaults to
" "(space).Must be a single
characterstring.Only has an effect if
collapseAtomic == TRUE.
See also
The humdrum folding functions serve a similar function, "folding" data into new fields, rather than collapsing it within a field.
Other Humdrum table reshaping functions:
cleave(),
expandPaths(),
rend()