nhanesSearch function

Perform a search over the comprehensive NHANES variable list.

Perform a search over the comprehensive NHANES variable list.

The descriptions in the master variable list will be filtered by the provided search terms to retrieve a list of relevant variables. The search can be restricted to specific survey years by specifying ystart and/or ystop.

nhanesSearch( search_terms = NULL, exclude_terms = NULL, data_group = NULL, ignore.case = FALSE, ystart = NULL, ystop = NULL, includerdc = FALSE, nchar = 128, namesonly = FALSE )

Arguments

  • search_terms: List of terms or keywords.
  • exclude_terms: List of exclusive terms or keywords.
  • data_group: Which data groups (e.g. DIET, EXAM, LAB) to search. Default is to search all groups.
  • ignore.case: Ignore case if TRUE. (Default=FALSE).
  • ystart: Four digit year of first survey included in search, where ystart >= 1999.
  • ystop: Four digit year of final survey included in search, where ystop >= ystart.
  • includerdc: If TRUE then RDC only tables are included in list (default=FALSE).
  • nchar: Truncates the variable description to a max length of nchar.
  • namesonly: If TRUE then only the table names are returned (default=FALSE).

Returns

Returns a data frame that describes variables that matched the search terms. If namesonly=TRUE, then a character vector of table names that contain matched variables is returned.

Details

nhanesSearch is useful to obtain a comprehensive list of relevant tables. Search terms will be matched against the variable descriptions in the NHANES Comprehensive Variable Lists. Matching variables must have at least one of the search_terms and not have any exclude_terms. The search may be restricted to specific surveys using ystart and ystop. If no arguments are given, then nhanesSearch returns the complete variable list.

Examples

bladder = nhanesSearch("bladder", ystart=2001, ystop=2008, nchar=50) dim(bladder) urin = nhanesSearch("urin", exclude_terms="During", ystart=2009) dim(urin) urine = nhanesSearch(c("urine", "urinary"), ignore.case=TRUE, ystop=2006, namesonly=TRUE) length(urine)
  • Maintainer: Christopher Endres
  • License: GPL (>= 2)
  • Last published: 2025-01-10