Learn R Programming

translateSPSS2R (version 1.0.0)

xpssAddValueLabels: Modifies value labels

Description

R implementation of the SPSS ADD VALUE LABELS function. xpssAddValueLabels appends value labels for specific variables. Those values labels get stored in the attributes of the selected variable.

Usage

xpssAddValueLabels(x, variables = NULL, values = NULL, labels = NULL, datevariables = NULL, datevalues = NULL, datelabels = NULL)

Arguments

x
a (non-empty) data.frame or input data of class "xpssFrame".
variables
atomic character or character vector with the name of the variables.
values
atomic numeric or numeric vector, respectively as an atomic character or character vector containing the value of the variable.
labels
atomic numeric or numeric vector, respectively as an atomic character or character vector containing the label of the variable.
datevariables
atomic date or date vector with the name of the date variables.
datevalues
atomic date or date vector containing the value of the date, the value has to be like the old date format.
datelabels
atomic numeric or numeric vector, respectively as an atomic character or character vector containing a variable label.

Value

An xpssFrame object with modified value labels.

Details

The values labels are stored in the variable itself. In contrast to xpssValueLabels , xpssAddValueLabels do not erase existing value labels. If the value label for a specific variable already exists, this value label get overwritten. If the value label for a specific variable does not exist, the value label get created without deleting the existing value label of that variable. Supported attributes are: value.labels, defined.MIS, MIS, varname, variable.label

See Also

read.spss xpssValueLabels xpssVariableLabels

Examples

Run this code
data(fromXPSS)

fromXPSS <- xpssValueLabels(fromXPSS,
                           variables = "V1",
                           values = 1 ,
                           labels = "Label1")

fromXPSS <- xpssAddValueLabels(fromXPSS,
                           variables = "V1",
                           values = 2 ,
                           labels = "Label2")

fromXPSS <- xpssAddValueLabels(fromXPSS,
                           variables = "V1",
                           values = "B" ,
                           labels = "CharLabel")



attributes(fromXPSS$V1)$value.labels

Run the code above in your browser using DataLab