get_itemnames: Extract item names

View source: R/get_itemnames.R

get_itemnamesR Documentation

Extract item names

Description

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.

Usage

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

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.

Value

A vector with names of items

Author(s)

Stef van Buuren 2020

See Also

sort_itemnames()

Examples

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

# filter out impossible names
get_itemnames(itemnames)
get_itemnames(itemnames, strict = TRUE)

# only items from specific instruments
get_itemnames(itemnames, instrument = c("aqi", "mds"))
get_itemnames(itemnames, instrument = c("aqi", "mds"), strict = TRUE)

# get all items from the se domain of iyo instrument
get_itemnames(domain = "se", instrument = "iyo")

# get all item from the se domain with direct assessment mode
get_itemnames(domain = "se", mode = "d")

# get all item numbers 70 and 73 from gm domain
get_itemnames(number = c(70, 73), domain = "gm")

dscore documentation built on Jan. 22, 2023, 1:50 a.m.