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

data.frame object containing numerical values of items data

...

objects of class ScaleSpec or CombScaleSpec. If all item names are found in data, summed items will be available in returned data.frame as column named as their name value.

retain

either boolean: TRUE if all columns in the data are to be retained, FALSE if none, or character vector with names of columns to be retained

.dots

ScaleSpec or CombScaleSpec objects 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.

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)

[Package stenR version 0.6.9 Index]