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.
searchVarLabels(dat, str)
a data frame whose variable labels you want to search.
string used to search variable labels.
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.
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