sum_items_to_scale {stenR} | R Documentation |
Sum up discrete raw data
Description
Helper function to sum-up and - if needed - automatically reverse discrete raw item values to scale or factor that they are measuring.
Usage
sum_items_to_scale(data, ..., retain = FALSE, .dots = list())
Arguments
data |
|
... |
objects of class |
retain |
either |
.dots |
|
Details
All summing up of the raw discrete values into scale or factor
score is done according to provided specifications utilizing ScaleSpec()
objects. For more information refer to their constructor help page.
Value
object of class data.frame
See Also
Other item preprocessing functions:
CombScaleSpec()
,
ScaleSpec()
Examples
# create the Scale Specifications for SLCS dataset
## Self-Liking specification
SL_spec <- ScaleSpec(
name = "Self-Liking",
item_names = paste("SLCS", c(1, 3, 5, 6, 7, 9, 11, 15), sep = "_"),
reverse = paste("SLCS", c(1, 6, 7, 15), sep = "_"),
min = 1,
max = 5)
## Self-Competence specification
SC_spec <- ScaleSpec(
name = "Self-Competence",
item_names = paste("SLCS", c(2, 4, 8, 10, 12, 13, 14, 16), sep = "_"),
reverse = paste("SLCS", c(8, 10, 13), sep = "_"),
min = 1,
max = 5)
## General Score specification
GS_spec <- CombScaleSpec(
name = "General Score",
SL_spec,
SC_spec)
# Sum the raw item scores to raw scale scores
SLCS_summed <- sum_items_to_scale(SLCS, SL_spec, SC_spec, GS_spec, retain = "user_id")
summary(SLCS_summed)