The get_itemnames() function matches names against the 9-code template. This is useful for quickly selecting names of items from a larger set of names.

get_itemnames(
  x,
  instrument = NULL,
  domain = NULL,
  mode = NULL,
  number = NULL,
  strict = FALSE,
  itemtable = NULL,
  order = "idnm"
)

Arguments

x

A character vector, data.frame or an object of class lean. If not specified, the function will return all item names in itemtable.

instrument

A character vector with 3-position codes of instruments that should match. The default instrument = NULL allows for all instruments.

domain

A character vector with 2-position codes of domains that should match. The default instrument = NULL allows for all domains.

mode

A character vector with 1-position codes of the mode of administration. The default mode = NULL allows for all modes.

number

A numeric or character vector with item numbers. The default number = NULL allows for all numbers.

strict

A logical specifying whether the resulting item names must conform to one of the built-in names. The default is strict = FALSE.

itemtable

A data.frame set up according to the same structure as builtin_itemtable(). If not specified, the builtin_itemtable is used.

order

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".

Value

A vector with names of items

Details

The gsed-naming convention is as follows. Position 1-3 codes the instrument, position 4-5 codes the domain, position 6 codes direct/caregiver/message, positions 7-9 is a item sequence number.

See also

Author

Stef van Buuren 2020

Examples

itemnames <- c("aqigmc028", "grihsd219", "", "age", "mdsgmd999")

# filter out impossible names
get_itemnames(itemnames)
#> [1] "aqigmc028" "grihsd219" "mdsgmd999"
get_itemnames(itemnames, strict = TRUE)
#> [1] "aqigmc028" "grihsd219"

# only items from specific instruments
get_itemnames(itemnames, instrument = c("aqi", "mds"))
#> [1] "aqigmc028" "mdsgmd999"
get_itemnames(itemnames, instrument = c("aqi", "mds"), strict = TRUE)
#> [1] "aqigmc028"

# get all items from the se domain of iyo instrument
get_itemnames(domain = "se", instrument = "iyo")
#>  [1] "iyosec001" "iyosec002" "iyosec003" "iyosec004" "iyosec005" "iyosec006"
#>  [7] "iyosec007" "iyosec008" "iyosec009" "iyosec010" "iyosec011" "iyosec012"
#> [13] "iyosec013" "iyosec014" "iyosec015" "iyosec016" "iyosec017" "iyosec018"
#> [19] "iyosec019" "iyosec020"

# get all item from the se domain with direct assessment mode
get_itemnames(domain = "se", mode = "d")
#>  [1] "mdtsed001" "mdtsed002" "mdtsed003" "mdtsed004" "mdtsed005" "mdtsed006"
#>  [7] "mdtsed007" "mdtsed008" "mdtsed009" "mdtsed010" "mdtsed011" "mdtsed012"
#> [13] "mdtsed013" "mdtsed014" "mdtsed015" "mdtsed016" "mdtsed017" "mdtsed018"
#> [19] "mdtsed019" "mdtsed020" "mdtsed021" "mdtsed022" "mdtsed023" "mdtsed024"
#> [25] "mdtsed025" "mdtsed026" "mdtsed027" "mdtsed028" "mdtsed029" "mdtsed030"
#> [31] "mdtsed031" "mdtsed032" "mdtsed033" "mdtsed034" "prised001" "prised002"
#> [37] "prised003" "prised004" "prised005" "prised006" "prised007" "prised008"
#> [43] "prised009" "prised010" "prised011" "prised012" "prised013" "prised014"
#> [49] "prised015" "prised016"

# get all item numbers 70 and 73 from gm domain
get_itemnames(number = c(70, 73), domain = "gm")
#> [1] "by3gmd070" "ddigmd070" "ddigmm073" "mulgmd070"