
Sum up discrete raw data
sum_items_to_scale.RdHelper 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
- data.frameobject containing numerical values of items data
- ...
- objects of class - ScaleSpecor- CombScaleSpec. If all item names are found in- data, summed items will be available in returned data.frame as column named as their- namevalue.
- retain
- either - boolean:- TRUEif all columns in the- dataare to be retained,- FALSEif none, or character vector with names of columns to be retained
- .dots
- ScaleSpecor- CombScaleSpecobjects provided as a list, instead of individually in- ....
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.
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)
#>    user_id           Self-Liking    Self-Competence General Score  
#>  Length:103         Min.   : 8.00   Min.   :10.00   Min.   :20.00  
#>  Class :character   1st Qu.:15.00   1st Qu.:19.00   1st Qu.:35.00  
#>  Mode  :character   Median :19.00   Median :22.00   Median :42.00  
#>                     Mean   :20.53   Mean   :22.15   Mean   :42.68  
#>                     3rd Qu.:24.00   3rd Qu.:25.00   3rd Qu.:48.50  
#>                     Max.   :40.00   Max.   :33.00   Max.   :72.00