addweights {fsia} | R Documentation |
Add a Weights to a Data Frame
Description
Adds the weights associated with the responses to the items to a data frame.
Usage
addweights(obj, weightsfile = NULL, weightsdata = NULL)
Arguments
obj |
An object containing the data imported by function |
weightsfile |
the name of the file with the weights. Column names should match the names of the items. |
weightsdata |
an R data frame containing the weights. Column names should match the names of the items. |
Details
If weightsfile
and weightsdata
have only one row, they should contain the weights that
are assigned to the correct responses. These are defined by addkey
.
To specify a different weight to every response of each item, weightsfile
and weightsdata
should have one row for each response. In this case there should be a field named response
.
weightsfile
and weightsdata
can contain more items than obj
.
In this case, items not contained in obj
are dropped in the output.
Value
A list with data
, eventually key
, and weights
.
Author(s)
Michela Battauz
See Also
Examples
data(test)
data(key)
data(weights)
data(weights_multiple)
testk <- addkey(test, keydata = key)
testw <- addweights(testk, weightsdata = weights)
testwm <- addweights(test, weightsdata = weights_multiple)