scores {quest} | R Documentation |
Observed Unweighted Scoring of Multiple Sets of Variables/Items
Description
scores
calculates observed unweighted scores across multiple sets of
variables/items. If a row's frequency of observed data is less than (or equal
to) ov.min
, then NA is returned for that row. Each set of
variables/items are coerced to a matrix before scoring. If the coercion leads
to a character matrix, an error is returned. This can be tested with
lapply(X = vrb.nm.list, FUN = function(nm)
is.character(as.matrix(data[nm])))
.
Usage
scores(
data,
vrb.nm.list,
avg = TRUE,
ov.min = 1,
prop = TRUE,
inclusive = TRUE,
impute = TRUE,
std = FALSE,
std.data = std,
std.score = std
)
Arguments
data |
data.frame or numeric/logical matrix |
vrb.nm.list |
list where each element is a character vector of colnames
in |
avg |
logical vector of length 1 specifying whether mean scores (TRUE) or sum scores (FALSE) should be created. |
ov.min |
minimum frequency of observed values required per row. If
|
prop |
logical vector of length 1 specifying whether |
inclusive |
logical vector of length 1 specifying whether the scores
should be calculated (rather than NA) if the frequency of observed values
in a row is exactly equal to |
impute |
logical vector of length 1 specifying if missing values should
be imputed with the mean of observed values from each row of
|
std |
logical vector of length 1 specifying whether 1) the variables
should be standardized before scoring and 2) the score standardized after
creation. This argument is for convenience as these two standardization
processes are often used together. However, this argument will be
overwritten by any non-default value for |
std.data |
logical vector of length 1 specifying whether the variables/items should be standardized before scoring. |
std.score |
logical vector of length 1 specifying whether the scores should be standardized after creation. |
Value
data.frame of mean/sum scores with NA
for any row with the
frequency of observed values less than (or equal to) ov.min
. The
colnames are specified by names(vrb.nm.list)
and rownames by
row.names(data)
.
See Also
score
rowMeans_if
rowSums_if
scoreItems
Examples
list_colnames <- list("first" = c("rating","complaints","privileges"),
"second" = c("learning","raises","critical"))
scores(data = attitude, vrb.nm.list = list_colnames)
list_colnames <- list("first" = c("Ozone","Wind"),
"second" = c("Solar.R","Temp"))
scores(data = airquality, vrb.nm.list = list_colnames, ov.min = .50,
inclusive = FALSE) # scoring conditional on observed values