Learn R Programming

DAMisc (version 1.7.2)

searchVarLabels: Search Variable Labels Attribute

Description

Data imported from SPSS or Stata comes with the variable labels set (if they were set in the original dataset) as one of the dataframe's attributes. This allows you to search the variable labels and returns the variable column number, name and label for all variables that have partially match the search term either in their labels or names.

Usage

searchVarLabels(dat, str)

Arguments

dat

a data frame whose variable labels you want to search.

str

string used to search variable labels.

Value

matrix

A matrix of dimensions n-matches x 2 is returned, where the first column is the column number of the matching variable and the second column is the variable label. The row names of the matrix are the variable names.

Details

For an imported Stata dataset, variable labels are in the var.labels attribute of the dataset and in an SPSS dataset, they are in the variable.labels attribute. These are searched, ignoring case, for the desired string