R's built-in indexing operators, []
(single brakcets) and [[]]
(double brackets) can
be used to filter humdrumR data, by removing specific
pieces, spines, or records from the humdrum table.
Unlike the more flexible/powerful subset()/filter() methods,
the indexing operators are generally destructive (by default), meaning filtered data can no longer
be accessed after indexing.
The functions index()
and index2()
are synonyms for single and double brackets respectively,
which can be used in pipes.
Usage
humData[] # returns unchanged
humData[x:y]
humData['regex']
humData[[x:y]]
humData[[ , x:y]]
humData[['regex']]
humData[[ , 'regex']]
humData[[x:y, l:m]]
humData[[ , , regex]]
index(x, i, j, drop = TRUE)
index2(x, i, j, drop = TRUE)
Arguments
- x
HumdrumR data to index.
Must be a humdrumR data object.
- i
Index for vectors or matrix/data.frame rows.
A numeric vector or a
character
string treated as a regular expression.- j
Index for matrix/data.frame columns.
A numeric vector or a
character
string treated as a regular expression.
Details
In R, the fundamental indexing operators, []
and [[]]
,
are used to select subsets of data.
For many data types (for instance, base R lists)
the [
single brackets]
are used for "shallower" extraction while the
[[
double brackets]]
are used for "deeper" extraction.
By rough analogy with this "shallow vs deep" dichotomy, HumdrumR corpus
indexing brackets are used in two ways:
[
single brackets]
are used to select pieces in your data.[[
double brackets]]
are used to select records or spines within the pieces in your data.
(Accidentally writing []
when you need
[[]]
is a very common error, so watch out!)
Whether, indexing by piece or within, humdrumR
objects can use
two types of indexing arguments: numeric
(ordinal integers) or character
string
(interpreted as regular expressions).
Numeric indexing:
Indexing humdrumR
corpora with
[
single brackets]
will accept
one numeric argument---only whole numbers are accepted.
This argument will be used to pick pieces within the humdrumR
object ordinally.
Thus, humData[1:10]
will select the first ten pieces in the data while humData[42]
will select only the 42nd piece.
Indexing humdrumR
objects with
[[
double brackets]]
will accept
one or two numeric arguments, i
and j
, either of which can
be used in isolation or in combination.
(If j
is used in isolation, it must be named or placed after a comma, as in humData[[ , j ]]
.)
i
is used to index records (i.e., based on the humtableRecord
field). Thus,humData[[1:20]]
indexes the first twenty records from each piece in the corpus, andhumData[[42]]
extracts the 42nd record from each piece.To avoid breaking the humdrum syntax, exclusive interpretations and spine-path interpretations are not removed.
j
is used to index spines (i.e., based on theSpine
field). Thus,humData[[ , 3:4]]
returns the third and fourth spines from each piece in the corpus.
Pieces/spines/records are renumbered after indexing
(see the Renumbering section of the subset()/filter() docs for explantion).
As a result, humdrumR
indexing is entirely ordinal.
For example,
will return the 12th piece from the original humData
object.
This is because the first call to []
returns the 11th through 20th pieces, which
are renumbered 1:10
and the second index call returns the new 2nd index, which was the 12th
originally.
Similarly,
will return the third spine from the original data.
Negative numbers
As in normal R
indexing, negative numbers can be used, causing corresponding elements to be
removed instead of retained. Thus, humData[-3:-5]
will remove the third, fourth, and fifth pieces from the data
while humData[[ , -3:-5]]
will remove the third, fourth, and fifth spines from each piece.
Positive and negative indices cannot be mixed in a single argument.
Out of bounds indices
In all cases, indices outside of bounds (or of value 0
) are ignored.
E.g., if you have a corpus of twenty pieces and you call corpus[21]
, there is no 21st piece, so 21
is "out of bounds".
If all your input indices are 0
and error will result.
If all your input indices are out of bounds then
an empty humdrumR
object is returned.
For instance, humData[[401:500, ]]
will return an empty
humdrumR
object if there are no pieces with more than 400
data records.
Character indexing:
If you index a humdrumR object
with character
strings, these strings are
treated as regular expressions (regexes),
which are matched against non-null data tokens ("D"
) in the object's first selected field.
A match to any of the regular expressions considered a match.
Indexing with [
single brackets]
accepts one
vector of character
regular expressions.
Any piece that contains even a single match will be retained.
If no matches occur in any pieces, an empty humdrumR
object is returned.
Indexing humdrumR
objects with [[
double brackets]]
accepts one or two vectors of character
strings, i
and j
,
either of which can be used in isolation or in combination.
(If j
is used in isolation, it must be placed after a comma,
as in humData[[ , j]]
.)
Any data record which contains at least one match to the i
regex(es)
will be retained.
Similarly, any spine which contains at least one match to the
j
regex(es) is retained.
If i
and j
are used together,
matching spines (j
) are indexed first, so that
tokens matching the regular expression(s) in i
must be found in the matching spines.
Exclusive indexing:
Spines can also be indexed ordinally by exclusive interpretation.
To do this, provide a double-bracket index with a named numeric (whole number) argument,
with name(s) corresponding to exclusive interpretations in the data.
For example, if you want to index the 3rd **kern
spine in each piece,
use humData[[kern = 3]]
.
Note that other exclusive interpretations in each piece are unaffected---in
this example, only the kern spines (if there are any) are indexed!
removeEmpty
The removeEmpty
argument to any humdrumR indexing controls whether
filtered data is completely removed from the data, or simply set to null
This means the filtered data can be recovered using unfilter()
(see the subset()/filter()
docs for an explanation).
By default, piece-indexing and spine-indexing have removeEmpty = TRUE
,
but record-indexing defaults to removeEmpty = FALSE
.
See also
For more powerful/flexible indexing options, use subset()/filter().
Examples
humData <- readHumdrum(humdrumRroot, "HumdrumData/RollingStoneCorpus/*.hum")
#> Finding and reading files...
#> REpath-pattern '/home/nat/.tmp/Rtmpz26RCR/temp_libpatha780af15d1/humdrumR/HumdrumData/RollingStoneCorpus/*.hum' matches 13 text files in 1 directory.
#> Thirteen files read from disk.
#> Validating thirteen files...
#> all valid.
#> Parsing thirteen files...
#> Assembling corpus...
#> Done!
humData[1:2]
#> ##################### vvv all_apologies.hum vvv ######################
#> 1: !!!Rolling Stone List Rank: 455
#> 2: !!!OTL: All Apologies
#> 3: !!!COC: Nirvana
#> 4: !!!RRD: 1993/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb1 *tb1 *tb1 *
#> 10: *M4/4 *M4/4 *M4/4 *
#> 11: *D-: *D-: *D-: *
#> 12: *k[g-d-a-e-b-] *k[g-d-a-e-b-] *k[g-d-a-e-b-] *
#> 13: I Id7 . 1.040
#> 14: =2 =2 =2 =2
#> 15: . . . 3.246
#> 16: =3 =3 =3 =3
#> 17: . . . 5.394
#> 18: =4 =4 =4 =4
#> 19: . . . 7.632
#> 20: =5 =5 =5 =5
#> 21: . . . 9.759
#> 22: =6 =6 =6 =6
#> 23: . . . 11.960
#> 24: =7 =7 =7 =7
#> 25: . . . 14.113
#> 26: =8 =8 =8 =8
#> 27: . . . 16.278
#> 28: =9 =9 =9 =9
#> 29: *tb8 *tb8 *tb8 *
#> 30: . . 3 18.408
#> 31: . . 3 .
#> 32: . . . .
#> 33: . . . .
#> 34: . . 3 .
#> 35: . . 4 .
#> 36: . . . .
#> 37: . . 5 .
#> 38: =10 =10 =10 =10
#> 39: *tb1 *tb1 *tb1 *
#> 40: . . . 20.559
#> 41: =11 =11 =11 =11
#> 42: *tb8 *tb8 *tb8 *
#> 43: . . ^3 22.701
#> 44: . . . .
#> 45: . . 2 .
#> 46: . . 1 .
#> 47: . . . .
#> 48: . . . .
#> 49: . . b7 .
#> 50: . . 5 .
#> 51-799::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> ##################### ^^^ all_apologies.hum ^^^ ######################
#> ##################### vvv back_in_black.hum vvv ######################
#> 1-1024::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 1025: =91 =91 =91 =91
#> 1026: . . . 231.057
#> 1027: bVII bVII . .
#> 1028: =92 =92 =92 =92
#> 1029: *tb9 *tb9 *tb9 *
#> 1030: IV IV6 . 233.668
#> 1031: . . . .
#> 1032: . . . .
#> 1033: . . . .
#> 1034: . I . .
#> 1035: I . . .
#> 1036: . IV . .
#> 1037: . . . .
#> 1038: . I . .
#> 1039: . IV . .
#> 1040: =93 =93 =93 =93
#> 1041: *tb2 *tb2 *tb2 *
#> 1042: . I . 236.243
#> 1043: bVII bVII . .
#> 1044: =94 =94 =94 =94
#> 1045: IV IV6 . 238.855
#> 1046: I I . .
#> 1047: =95 =95 =95 =95
#> 1048: . . . 241.435
#> 1049: bVII bVII . .
#> 1050: =96 =96 =96 =96
#> 1051: *tb9 *tb9 *tb9 *
#> 1052: IV IV6 . 244.050
#> 1053: . . . .
#> 1054: . . . .
#> 1055: . . . .
#> 1056: . I . .
#> 1057: I . . .
#> 1058: . IV . .
#> 1059: . . . .
#> 1060: . I . .
#> 1061: . IV . .
#> 1062: =97 =97 =97 =97
#> 1063: *tb2 *tb2 *tb2 *
#> 1064: . I . 246.585
#> 1065: bVII bVII . .
#> 1066: =98 =98 =98 =98
#> 1067: IV IV6 . 249.164
#> 1068: I I . .
#> 1069: *- *- *- *-
#> 1070: !!!ONB: Translated from original encodings in the***
#> 1071: !!!ONB: Original transcribers noted in comments i***
#> 1072: !!!YOE: David Temperley, Trevor de Clercq
#> 1073: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1074: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ##################### ^^^ back_in_black.hum ^^^ ######################
#> (***four global comments truncated due to screen size***)
#>
#> humdrumR corpus of two pieces.
#>
#> Data fields:
#> *Token :: character
#>
humData[-1]
#> ##################### vvv back_in_black.hum vvv ######################
#> 1: !!!Rolling Stone List Rank: 187
#> 2: !!!OTL: Back in Black
#> 3: !!!COC: AC/DC
#> 4: !!!RRD: 1980/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb1 *tb1 *tb1 *
#> 10: *M4/4 *M4/4 *M4/4 *
#> 11: *E: *E: *E: *
#> 12: *k[f#c#g#d#] *k[f#c#g#d#] *k[f#c#] *
#> 13: R R . 0.563
#> 14: =2 =2 =2 =2
#> 15: . . . 3.270
#> 16: =3 =3 =3 =3
#> 17: *tb2 *tb2 *tb2 *
#> 18: I I . 5.893
#> 19: bVII bVII . .
#> 20: =4 =4 =4 =4
#> 21: *tb1 *tb1 *tb1 *
#> 22: IV6 IV6 . 8.538
#> 23: =5 =5 =5 =5
#> 24: *tb2 *tb2 *tb2 *
#> 25: I I . 11.183
#> 26: bVII bVII . .
#> 27: =6 =6 =6 =6
#> 28: *tb1 *tb1 *tb1 *
#> 29: IV6 IV6 . 13.842
#> 30: =7 =7 =7 =7
#> 31: *tb2 *tb2 *tb2 *
#> 32: I I . 16.444
#> 33: bVII bVII . .
#> 34: =8 =8 =8 =8
#> 35: *tb1 *tb1 *tb1 *
#> 36: IV6 IV6 . 19.076
#> 37: =9 =9 =9 =9
#> 38: *tb2 *tb2 *tb2 *
#> 39: I I . 21.735
#> 40: bVII bVII . .
#> 41: =10 =10 =10 =10
#> 42: *tb1 *tb1 *tb1 *
#> 43: IV6 IV6 . 24.412
#> 44: =11 =11 =11 =11
#> 45: *tb16 *tb16 *tb16 *
#> 46: I I 1 27.022
#> 47: . . 1 .
#> 48: . . . .
#> 49: . . 1 .
#> 50: . . . .
#> 51-1074:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> ##################### ^^^ back_in_black.hum ^^^ ######################
#>
#> (ten more pieces...)
#>
#> ####################### vvv your_song.hum vvv ########################
#> 1-1184:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 1185: . . . .
#> 1186: . . . .
#> 1187: . . . .
#> 1188: . . 6 .
#> 1189: . . . .
#> 1190: . . . .
#> 1191: =118 =118 =118 =118
#> 1192: I6 I6 5 220.457
#> 1193: . . . .
#> 1194: . . . .
#> 1195: . . 3 .
#> 1196: . . . .
#> 1197: . . 2 .
#> 1198: . . 1 .
#> 1199: . . . .
#> 1200: =119 =119 =119 =119
#> 1201: ii65 IV 2 222.340
#> 1202: . . . .
#> 1203: . . . .
#> 1204: . . 6 .
#> 1205: . . . .
#> 1206: . . . .
#> 1207: . . . .
#> 1208: . . 6 .
#> 1209: =120 =120 =120 =120
#> 1210: . . b3 224.253
#> 1211: . . 2 .
#> 1212: . . . .
#> 1213: . . 1 .
#> 1214: . . . .
#> 1215: . . 1 .
#> 1216: . . 1 .
#> 1217: . . . .
#> 1218: =121 =121 =121 =121
#> 1219: *tb1 *tb1 *tb1 *
#> 1220: I I . 226.135
#> 1221: =122 =122 =122 =122
#> 1222: IV IV64 . 228.013
#> 1223: =123 =123 =123 =123
#> 1224: V Vs4 . 229.838
#> 1225: =124 =124 =124 =124
#> 1226: IV IV64 . 231.691
#> 1227: =125 =125 =125 =125
#> 1228: I I . 233.583
#> 1229: *- *- *- *-
#> 1230: !!!ONB: Translated from original encodings in the***
#> 1231: !!!ONB: Original transcribers noted in comments i***
#> 1232: !!!YOE: David Temperley, Trevor de Clercq
#> 1233: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1234: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ####################### ^^^ your_song.hum ^^^ ########################
#> (***four global comments truncated due to screen size***)
#>
#> humdrumR corpus of twelve pieces.
#>
#> Data fields:
#> *Token :: character
#>
humData[[ , 3:4]]
#> ############ vvv all_apologies.hum vvv #############
#> 1: !!!Rolling Stone List Rank: 455
#> 2: !!!OTL: All Apologies
#> 3: !!!COC: Nirvana
#> 4: !!!RRD: 1993/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **deg **timestamp
#> 7: !T.d.C. !
#> 8: =1 =1
#> 9: *tb1 *
#> 10: *M4/4 *
#> 11: *D-: *
#> 12: *k[g-d-a-e-b-] *
#> 13: . 1.040
#> 14: =2 =2
#> 15: . 3.246
#> 16: =3 =3
#> 17: . 5.394
#> 18: =4 =4
#> 19: . 7.632
#> 20: =5 =5
#> 21: . 9.759
#> 22: =6 =6
#> 23: . 11.960
#> 24: =7 =7
#> 25: . 14.113
#> 26: =8 =8
#> 27: . 16.278
#> 28: =9 =9
#> 29: *tb8 *
#> 30: 3 18.408
#> 31: 3 .
#> 32: . .
#> 33: . .
#> 34: 3 .
#> 35: 4 .
#> 36: . .
#> 37: 5 .
#> 38: =10 =10
#> 39: *tb1 *
#> 40: . 20.559
#> 41: =11 =11
#> 42: *tb8 *
#> 43: ^3 22.701
#> 44: . .
#> 45: 2 .
#> 46: 1 .
#> 47: . .
#> 48: . .
#> 49: b7 .
#> 50: 5 .
#> 51-799::::::::::::::::::::::::::::::::::::::::::::::
#> ############ ^^^ all_apologies.hum ^^^ #############
#>
#> (eleven more pieces...)
#>
#> ############## vvv your_song.hum vvv ###############
#> 1-1184::::::::::::::::::::::::::::::::::::::::::::::
#> 1185: . .
#> 1186: . .
#> 1187: . .
#> 1188: 6 .
#> 1189: . .
#> 1190: . .
#> 1191: =118 =118
#> 1192: 5 220.457
#> 1193: . .
#> 1194: . .
#> 1195: 3 .
#> 1196: . .
#> 1197: 2 .
#> 1198: 1 .
#> 1199: . .
#> 1200: =119 =119
#> 1201: 2 222.340
#> 1202: . .
#> 1203: . .
#> 1204: 6 .
#> 1205: . .
#> 1206: . .
#> 1207: . .
#> 1208: 6 .
#> 1209: =120 =120
#> 1210: b3 224.253
#> 1211: 2 .
#> 1212: . .
#> 1213: 1 .
#> 1214: . .
#> 1215: 1 .
#> 1216: 1 .
#> 1217: . .
#> 1218: =121 =121
#> 1219: *tb1 *
#> 1220: . 226.135
#> 1221: =122 =122
#> 1222: . 228.013
#> 1223: =123 =123
#> 1224: . 229.838
#> 1225: =124 =124
#> 1226: . 231.691
#> 1227: =125 =125
#> 1228: . 233.583
#> 1229: *- *-
#> 1230: !!!ONB: Translated from original encodings in the***
#> 1231: !!!ONB: Original transcribers noted in comments i***
#> 1232: !!!YOE: David Temperley, Trevor de Clercq
#> 1233: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1234: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ############## ^^^ your_song.hum ^^^ ###############
#> (***four
#> global comments truncated due to screen size***)
#>
#> humdrumR corpus of thirteen pieces.
#>
#> Data fields:
#> *Token :: character
#>
humData[[1:40 , ]]
#> ##################### vvv all_apologies.hum vvv ######################
#> 1: !!!Rolling Stone List Rank: 455
#> 2: !!!OTL: All Apologies
#> 3: !!!COC: Nirvana
#> 4: !!!RRD: 1993/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb1 *tb1 *tb1 *
#> 10: *M4/4 *M4/4 *M4/4 *
#> 11: *D-: *D-: *D-: *
#> 12: *k[g-d-a-e-b-] *k[g-d-a-e-b-] *k[g-d-a-e-b-] *
#> 13: I Id7 . 1.040
#> 14: =2 =2 =2 =2
#> 15: . . . 3.246
#> 16: =3 =3 =3 =3
#> 17: . . . 5.394
#> 18: =4 =4 =4 =4
#> 19: . . . 7.632
#> 20: =5 =5 =5 =5
#> 21: . . . 9.759
#> 22: =6 =6 =6 =6
#> 23: . . . 11.960
#> 24: =7 =7 =7 =7
#> 25: . . . 14.113
#> 26: =8 =8 =8 =8
#> 27: . . . 16.278
#> 28: =9 =9 =9 =9
#> 29: *tb8 *tb8 *tb8 *
#> 30: . . 3 18.408
#> 31: . . 3 .
#> 32: . . . .
#> 33: . . . .
#> 34: . . 3 .
#> 35: . . 4 .
#> 36: . . . .
#> 37: . . 5 .
#> 38: =10 =10 =10 =10
#> 39: *tb1 *tb1 *tb1 *
#> 40: . . . 20.559
#> 42: *tb8 *tb8 *tb8
#> 52: *tb1 *tb1 *tb1
#> 55: *tb8 *tb8 *tb8
#> 65: *tb1 *tb1 *tb1
#> 68: *tb8 *tb8 *tb8
#> 78: *tb1 *tb1 *tb1
#> 81: *tb8 *tb8 *tb8
#> 91: *tb1 *tb1 *tb1
#> 94: *tb8 *tb8 *tb8
#> 104: *tb1 *tb1 *tb1
#> 107-794:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> ##################### ^^^ all_apologies.hum ^^^ ######################
#>
#> (eleven more pieces...)
#>
#> ####################### vvv your_song.hum vvv ########################
#> 1-426:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 436: *tb16 *tb16 *tb16
#> 454: *tb8 *tb8 *tb8
#> 464: *tb16 *tb16 *tb16
#> 482: *tb8 *tb8 *tb8
#> 492: *tb16 *tb16 *tb16
#> 510: *tb8 *tb8 *tb8
#> 538: *tb1 *tb1 *tb1
#> 541: *tb4 *tb4 *tb4
#> 547: *tb8 *tb8 *tb8
#> 575: *tb1 *tb1 *tb1
#> 588: *tb8 *tb8 *tb8
#> 598: *tb1 *tb1 *tb1
#> 601: *tb8 *tb8 *tb8
#> 611: *tb16 *tb16 *tb16
#> 629: *tb8 *tb8 *tb8
#> 657: *tb16 *tb16 *tb16
#> 675: *tb8 *tb8 *tb8
#> 685: *tb16 *tb16 *tb16
#> 703: *tb8 *tb8 *tb8
#> 731: *tb16 *tb16 *tb16
#> 749: *tb8 *tb8 *tb8
#> 768: *tb1 *tb1 *tb1
#> 771: *tb16 *tb16 *tb16
#> 789: *tb8 *tb8 *tb8
#> 808: *tb16 *tb16 *tb16
#> 826: *tb8 *tb8 *tb8
#> 854: *tb16 *tb16 *tb16
#> 923: *tb1 *tb1 *tb1
#> 926: *tb8 *tb8 *tb8
#> 936: *tb16 *tb16 *tb16
#> 954: *tb8 *tb8 *tb8
#> 964: *tb1 *tb1 *tb1
#> 969: *tb8 *tb8 *tb8
#> 979: *tb16 *tb16 *tb16
#> 997: *tb8 *tb8 *tb8
#> 1007: *tb16 *tb16 *tb16
#> 1025: *tb8 *tb8 *tb8
#> 1035: *tb16 *tb16 *tb16
#> 1053: *tb8 *tb8 *tb8
#> 1063: *tb16 *tb16 *tb16
#> 1081: *tb8 *tb8 *tb8
#> 1109: *tb1 *tb1 *tb1
#> 1112: *tb4 *tb4 *tb4
#> 1118: *tb8 *tb8 *tb8
#> 1146: *tb1 *tb1 *tb1
#> 1151: *tb8 *tb8 *tb8
#> 1179: *tb1 *tb1 *tb1
#> 1182: *tb8 *tb8 *tb8
#> 1219: *tb1 *tb1 *tb1
#> 1229: *- *- *- *-
#> ####################### ^^^ your_song.hum ^^^ ########################
#>
#> humdrumR corpus of thirteen pieces.
#>
#> Data fields:
#> *Token :: character
#>
# find all pieces which use a flat 3
humData['b3']
#> #################### vvv blue_suede_shoes.hum vvv ####################
#> 1: !!!Rolling Stone List Rank: 95
#> 2: !!!OTL: Blue Suede Shoes
#> 3: !!!COC: Carl Perkins
#> 4: !!!RRD: 1956/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb8 *tb8 *tb8 *
#> 10: *M12/8 *M12/8 *M12/8 *
#> 11: *A: *A: *A: *
#> 12: *k[f#c#g#] *k[f#c#g#] *k[f#c#g#] *
#> 13: R R . 0.000
#> 14: . . . .
#> 15: . . . .
#> 16: . . . .
#> 17: . . . .
#> 18: . . . .
#> 19: . . . .
#> 20: . . . .
#> 21: . . 5 .
#> 22: . . b7 .
#> 23: . . . .
#> 24: . . . .
#> 25: =2 =2 =2 =2
#> 26: I I 1 0.865
#> 27: . . . .
#> 28: . . . .
#> 29: . . 1 .
#> 30: . . . .
#> 31: . . 1 .
#> 32: . . b3 .
#> 33: . . . .
#> 34: . . b3 .
#> 35: . . . .
#> 36: . . . .
#> 37: . . . .
#> 38: =3 =3 =3 =3
#> 39: *tb2. *tb2. *tb2. *
#> 40: *M6/8 *M6/8 *M6/8 *
#> 41: . . . 2.321
#> 42: =4 =4 =4 =4
#> 43: *tb8 *tb8 *tb8 *
#> 44: *M12/8 *M12/8 *M12/8 *
#> 45: . . 1 3.055
#> 46: . . . .
#> 47: . . . .
#> 48: . . 1 .
#> 49: . . . .
#> 50: . . 1 .
#> 51-869::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> #################### ^^^ blue_suede_shoes.hum ^^^ ####################
#>
#> (six more pieces...)
#>
#> ####################### vvv your_song.hum vvv ########################
#> 1-1184::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 1185: . . . .
#> 1186: . . . .
#> 1187: . . . .
#> 1188: . . 6 .
#> 1189: . . . .
#> 1190: . . . .
#> 1191: =118 =118 =118 =118
#> 1192: I6 I6 5 220.457
#> 1193: . . . .
#> 1194: . . . .
#> 1195: . . 3 .
#> 1196: . . . .
#> 1197: . . 2 .
#> 1198: . . 1 .
#> 1199: . . . .
#> 1200: =119 =119 =119 =119
#> 1201: ii65 IV 2 222.340
#> 1202: . . . .
#> 1203: . . . .
#> 1204: . . 6 .
#> 1205: . . . .
#> 1206: . . . .
#> 1207: . . . .
#> 1208: . . 6 .
#> 1209: =120 =120 =120 =120
#> 1210: . . b3 224.253
#> 1211: . . 2 .
#> 1212: . . . .
#> 1213: . . 1 .
#> 1214: . . . .
#> 1215: . . 1 .
#> 1216: . . 1 .
#> 1217: . . . .
#> 1218: =121 =121 =121 =121
#> 1219: *tb1 *tb1 *tb1 *
#> 1220: I I . 226.135
#> 1221: =122 =122 =122 =122
#> 1222: IV IV64 . 228.013
#> 1223: =123 =123 =123 =123
#> 1224: V Vs4 . 229.838
#> 1225: =124 =124 =124 =124
#> 1226: IV IV64 . 231.691
#> 1227: =125 =125 =125 =125
#> 1228: I I . 233.583
#> 1229: *- *- *- *-
#> 1230: !!!ONB: Translated from original encodings in the***
#> 1231: !!!ONB: Original transcribers noted in comments i***
#> 1232: !!!YOE: David Temperley, Trevor de Clercq
#> 1233: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1234: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ####################### ^^^ your_song.hum ^^^ ########################
#> (***four global comments truncated due to screen size***)
#>
#> humdrumR corpus of eight pieces.
#>
#> Data fields:
#> *Token :: character
#>
# find all records that use a flat 3
humData[['b3', ]]
#> #################### vvv blue_suede_shoes.hum vvv ####################
#> 1: !!!Rolling Stone List Rank: 95
#> 2: !!!OTL: Blue Suede Shoes
#> 3: !!!COC: Carl Perkins
#> 4: !!!RRD: 1956/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb8 *tb8 *tb8 *
#> 10: *M12/8 *M12/8 *M12/8 *
#> 11: *A: *A: *A: *
#> 12: *k[f#c#g#] *k[f#c#g#] *k[f#c#g#] *
#> 13: . . . .
#> 14: . . . .
#> 15: . . . .
#> 16: . . . .
#> 17: . . . .
#> 18: . . . .
#> 19: . . . .
#> 20: . . . .
#> 21: . . . .
#> 22: . . . .
#> 23: . . . .
#> 24: . . . .
#> 25: =2 =2 =2 =2
#> 26: . . . .
#> 27: . . . .
#> 28: . . . .
#> 29: . . . .
#> 30: . . . .
#> 31: . . . .
#> 32: . . b3 .
#> 33: . . . .
#> 34: . . b3 .
#> 35: . . . .
#> 36: . . . .
#> 37: . . . .
#> 38: =3 =3 =3 =3
#> 39: *tb2. *tb2. *tb2. *
#> 40: *M6/8 *M6/8 *M6/8 *
#> 41: . . . .
#> 42: =4 =4 =4 =4
#> 43: *tb8 *tb8 *tb8 *
#> 44: *M12/8 *M12/8 *M12/8 *
#> 45: . . . .
#> 46: . . . .
#> 47: . . . .
#> 48: . . . .
#> 49: . . . .
#> 50: . . . .
#> 51-869::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> #################### ^^^ blue_suede_shoes.hum ^^^ ####################
#>
#> (six more pieces...)
#>
#> ####################### vvv your_song.hum vvv ########################
#> 1-1184::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 1185: . . . .
#> 1186: . . . .
#> 1187: . . . .
#> 1188: . . . .
#> 1189: . . . .
#> 1190: . . . .
#> 1191: =118 =118 =118 =118
#> 1192: . . . .
#> 1193: . . . .
#> 1194: . . . .
#> 1195: . . . .
#> 1196: . . . .
#> 1197: . . . .
#> 1198: . . . .
#> 1199: . . . .
#> 1200: =119 =119 =119 =119
#> 1201: . . . .
#> 1202: . . . .
#> 1203: . . . .
#> 1204: . . . .
#> 1205: . . . .
#> 1206: . . . .
#> 1207: . . . .
#> 1208: . . . .
#> 1209: =120 =120 =120 =120
#> 1210: . . b3 224.253
#> 1211: . . . .
#> 1212: . . . .
#> 1213: . . . .
#> 1214: . . . .
#> 1215: . . . .
#> 1216: . . . .
#> 1217: . . . .
#> 1218: =121 =121 =121 =121
#> 1219: *tb1 *tb1 *tb1 *
#> 1220: . . . .
#> 1221: =122 =122 =122 =122
#> 1222: . . . .
#> 1223: =123 =123 =123 =123
#> 1224: . . . .
#> 1225: =124 =124 =124 =124
#> 1226: . . . .
#> 1227: =125 =125 =125 =125
#> 1228: . . . .
#> 1229: *- *- *- *-
#> 1230: !!!ONB: Translated from original encodings in the***
#> 1231: !!!ONB: Original transcribers noted in comments i***
#> 1232: !!!YOE: David Temperley, Trevor de Clercq
#> 1233: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1234: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ####################### ^^^ your_song.hum ^^^ ########################
#> (***four global comments truncated due to screen size***)
#>
#> humdrumR corpus of eight pieces.
#>
#> Data fields:
#> *Token :: character
#>
humData[['b3', removeEmpty = TRUE]]
#> #################### vvv blue_suede_shoes.hum vvv ####################
#> 1: !!!Rolling Stone List Rank: 95
#> 2: !!!OTL: Blue Suede Shoes
#> 3: !!!COC: Carl Perkins
#> 4: !!!RRD: 1956/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb8 *tb8 *tb8 *
#> 10: *M12/8 *M12/8 *M12/8 *
#> 11: *A: *A: *A: *
#> 12: *k[f#c#g#] *k[f#c#g#] *k[f#c#g#] *
#> 25: =2 =2 =2 =2
#> 32: . . b3 .
#> 34: . . b3 .
#> 38: =3 =3 =3 =3
#> 39: *tb2. *tb2. *tb2. *
#> 40: *M6/8 *M6/8 *M6/8 *
#> 42: =4 =4 =4 =4
#> 43: *tb8 *tb8 *tb8 *
#> 44: *M12/8 *M12/8 *M12/8 *
#> 51: . . b3 .
#> 57: =5 =5 =5 =5
#> 58: *tb2. *tb2. *tb2. *
#> 59: *M6/8 *M6/8 *M6/8 *
#> 61: =6 =6 =6 =6
#> 62: *tb8 *tb8 *tb8 *
#> 63: *M12/8 *M12/8 *M12/8 *
#> 76: =7 =7 =7 =7
#> 83: . . b3 .
#> 88: . . b3 .
#> 89: =8 =8 =8 =8
#> 90: *tb4 *tb4 *tb4 *
#> 92: . . b3 .
#> 97: =9 =9 =9 =9
#> 98: *tb8 *tb8 *tb8 *
#> 105: . . b3 .
#> 111: =10 =10 =10 =10
#> 112: *tb1. *tb1. *tb1. *
#> 114: =11 =11 =11 =11
#> 115: *tb8 *tb8 *tb8 *
#> 128: =12 =12 =12 =12
#> 141: =13 =13 =13 =13
#> 154: =14 =14 =14 =14
#> 155: *tb1. *tb1. *tb1. *
#> 157: =15 =15 =15 =15
#> 158: *tb8 *tb8 *tb8 *
#> 171: =16 =16 =16 =16
#> 180: . . b3 .
#> 184: =17 =17 =17 =17
#> 197-869:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> #################### ^^^ blue_suede_shoes.hum ^^^ ####################
#>
#> (six more pieces...)
#>
#> ####################### vvv your_song.hum vvv ########################
#> 1-1006:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 1007: *tb16 *tb16 *tb16 *
#> 1024: =99 =99 =99 =99
#> 1025: *tb8 *tb8 *tb8 *
#> 1034: =100 =100 =100 =100
#> 1035: *tb16 *tb16 *tb16 *
#> 1052: =101 =101 =101 =101
#> 1053: *tb8 *tb8 *tb8 *
#> 1062: =102 =102 =102 =102
#> 1063: *tb16 *tb16 *tb16 *
#> 1080: =103 =103 =103 =103
#> 1081: *tb8 *tb8 *tb8 *
#> 1090: =104 =104 =104 =104
#> 1099: =105 =105 =105 =105
#> 1108: =106 =106 =106 =106
#> 1109: *tb1 *tb1 *tb1 *
#> 1111: =107 =107 =107 =107
#> 1112: *tb4 *tb4 *tb4 *
#> 1117: =108 =108 =108 =108
#> 1118: *tb8 *tb8 *tb8 *
#> 1127: =109 =109 =109 =109
#> 1136: =110 =110 =110 =110
#> 1137: . . b3 205.287
#> 1145: =111 =111 =111 =111
#> 1146: *tb1 *tb1 *tb1 *
#> 1148: =112 =112 =112 =112
#> 1150: =113 =113 =113 =113
#> 1151: *tb8 *tb8 *tb8 *
#> 1160: =114 =114 =114 =114
#> 1163: . . b3 .
#> 1169: =115 =115 =115 =115
#> 1178: =116 =116 =116 =116
#> 1179: *tb1 *tb1 *tb1 *
#> 1181: =117 =117 =117 =117
#> 1182: *tb8 *tb8 *tb8 *
#> 1191: =118 =118 =118 =118
#> 1200: =119 =119 =119 =119
#> 1209: =120 =120 =120 =120
#> 1210: . . b3 224.253
#> 1218: =121 =121 =121 =121
#> 1219: *tb1 *tb1 *tb1 *
#> 1221: =122 =122 =122 =122
#> 1223: =123 =123 =123 =123
#> 1225: =124 =124 =124 =124
#> 1227: =125 =125 =125 =125
#> 1229: *- *- *- *-
#> 1230: !!!ONB: Translated from original encodings in the***
#> 1231: !!!ONB: Original transcribers noted in comments i***
#> 1232: !!!YOE: David Temperley, Trevor de Clercq
#> 1233: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1234: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ####################### ^^^ your_song.hum ^^^ ########################
#> (***four global comments truncated due to screen size***)
#>
#> humdrumR corpus of eight pieces.
#>
#> Data fields:
#> *Token :: character
#>
# Exclusive interpretation indexing
humData[[deg = 1]]
#> ##################### vvv all_apologies.hum vvv ######################
#> 1: !!!Rolling Stone List Rank: 455
#> 2: !!!OTL: All Apologies
#> 3: !!!COC: Nirvana
#> 4: !!!RRD: 1993/
#> 5: !!!In original RS 5x20 subset: True
#> 6: **harm **harm **deg **timestamp
#> 7: !T.d.C. !D.T. !T.d.C. !
#> 8: =1 =1 =1 =1
#> 9: *tb1 *tb1 *tb1 *
#> 10: *M4/4 *M4/4 *M4/4 *
#> 11: *D-: *D-: *D-: *
#> 12: *k[g-d-a-e-b-] *k[g-d-a-e-b-] *k[g-d-a-e-b-] *
#> 13: I Id7 . 1.040
#> 14: =2 =2 =2 =2
#> 15: . . . 3.246
#> 16: =3 =3 =3 =3
#> 17: . . . 5.394
#> 18: =4 =4 =4 =4
#> 19: . . . 7.632
#> 20: =5 =5 =5 =5
#> 21: . . . 9.759
#> 22: =6 =6 =6 =6
#> 23: . . . 11.960
#> 24: =7 =7 =7 =7
#> 25: . . . 14.113
#> 26: =8 =8 =8 =8
#> 27: . . . 16.278
#> 28: =9 =9 =9 =9
#> 29: *tb8 *tb8 *tb8 *
#> 30: . . 3 18.408
#> 31: . . 3 .
#> 32: . . . .
#> 33: . . . .
#> 34: . . 3 .
#> 35: . . 4 .
#> 36: . . . .
#> 37: . . 5 .
#> 38: =10 =10 =10 =10
#> 39: *tb1 *tb1 *tb1 *
#> 40: . . . 20.559
#> 41: =11 =11 =11 =11
#> 42: *tb8 *tb8 *tb8 *
#> 43: . . ^3 22.701
#> 44: . . . .
#> 45: . . 2 .
#> 46: . . 1 .
#> 47: . . . .
#> 48: . . . .
#> 49: . . b7 .
#> 50: . . 5 .
#> 51-799::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> ##################### ^^^ all_apologies.hum ^^^ ######################
#>
#> (eleven more pieces...)
#>
#> ####################### vvv your_song.hum vvv ########################
#> 1-1184::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
#> 1185: . . . .
#> 1186: . . . .
#> 1187: . . . .
#> 1188: . . 6 .
#> 1189: . . . .
#> 1190: . . . .
#> 1191: =118 =118 =118 =118
#> 1192: I6 I6 5 220.457
#> 1193: . . . .
#> 1194: . . . .
#> 1195: . . 3 .
#> 1196: . . . .
#> 1197: . . 2 .
#> 1198: . . 1 .
#> 1199: . . . .
#> 1200: =119 =119 =119 =119
#> 1201: ii65 IV 2 222.340
#> 1202: . . . .
#> 1203: . . . .
#> 1204: . . 6 .
#> 1205: . . . .
#> 1206: . . . .
#> 1207: . . . .
#> 1208: . . 6 .
#> 1209: =120 =120 =120 =120
#> 1210: . . b3 224.253
#> 1211: . . 2 .
#> 1212: . . . .
#> 1213: . . 1 .
#> 1214: . . . .
#> 1215: . . 1 .
#> 1216: . . 1 .
#> 1217: . . . .
#> 1218: =121 =121 =121 =121
#> 1219: *tb1 *tb1 *tb1 *
#> 1220: I I . 226.135
#> 1221: =122 =122 =122 =122
#> 1222: IV IV64 . 228.013
#> 1223: =123 =123 =123 =123
#> 1224: V Vs4 . 229.838
#> 1225: =124 =124 =124 =124
#> 1226: IV IV64 . 231.691
#> 1227: =125 =125 =125 =125
#> 1228: I I . 233.583
#> 1229: *- *- *- *-
#> 1230: !!!ONB: Translated from original encodings in the***
#> 1231: !!!ONB: Original transcribers noted in comments i***
#> 1232: !!!YOE: David Temperley, Trevor de Clercq
#> 1233: !!!EED: Nathaniel Condit-Schultz (fathermckenzie.***
#> 1234: !!!ENC: Nathaniel Condit-Schultz (fathermckenzie.***
#> ####################### ^^^ your_song.hum ^^^ ########################
#> (***four global comments truncated due to screen size***)
#>
#> humdrumR corpus of thirteen pieces.
#>
#> Data fields:
#> *Token :: character
#>
# pipe indexing
humData |> index(1:3) |> index2(3:4)
#>
#> Empty humdrumR object