Add a Weights to a Data Frame
Adds the weights associated with the responses to the items to a data frame.
addweights(obj, weightsfile = NULL, weightsdata = NULL)
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. |
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.
A list with data
, eventually key
, and weights
.
Michela Battauz
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.