This function sorts the item names according to instrument, domain, mode and number. The user can specify the sorting order.

sort_itemnames(x, order = "idnm")

order_itemnames(x, order = "idnm")



A character vector containing item names (gsed lexicon)


A four-letter string specifying the sorting order. The four letters are: i for instrument, d for domain, m for mode and n for number. The default is "idnm".


sort_itemnames() return a character vector with length(x) sorted elements. order_itemnames() return an integer vector of length length(x) with positions of the sorted elements.

See also


Stef van Buuren


itemnames <- c("aqigmc028", "grihsd219", "", "by1mdd157", "mdsgmd006") decompose_itemnames(itemnames)
#> instrument domain mode number #> 1 aqi gm c 028 #> 2 gri hs d 219 #> 3 #> 4 by1 md d 157 #> 5 mds gm d 006