spssdictionary.GetCategoricalDictionaryFromSPSS Function (R)
spssdictionary.GetCategoricalDictionaryFromSPSS(variables).
Returns a structure containing the value labels and associated values of the specified
categorical variables from the active dataset. This is a utility function for use when
retrieving categorical variables (variables with a measurement level of "nominal"
or "ordinal"
) into labeled R factors (factorMode="labels"
in
GetDataFromSPSS
), with the intention of writing those factors to a new dataset.
This is necessary because labeled factors in R do not preserve the original values. The structure
returned by this function is referred to as a category dictionary.
- The argument variables specifies the set of categorical variables. The argument can be
a character vector or list specifying the variable names, a character
string consisting of variable names separated by blanks, or a numeric
vector or list of integers specifying the index values of the variables
(index values represent position in the dataset, starting with 0 for
the first variable in file order). Variable names must match case
with the names as they exist in the active dataset's dictionary. If
the argument is omitted, all categorical variables will be retrieved.
When specifying variable names, you can use
TO
to indicate a range of variables. For example,variables=c("year TO cylinder")
specifies all categorical variables between year and cylinder in the active dataset's dictionary. You can also specify a range of values using index values, as invariables=c(2:4)
, which specifies the categorical variables with index values in the range 2 through 4.Note: Any scale variables in the specified set of variables are ignored.
Example
categoryDictionary <- spssdictionary.GetCategoricalDictionaryFromSPSS()