svy_make_scale: Creates scale by calculating item mean and returns...

View source: R/make_scales.R

svy_make_scaleR Documentation

Creates scale by calculating item mean and returns descriptives for srvyr objects

Description

This function creates a scale by calculating the mean of a set of items, and prints and returns descriptives that allow to assess internal consistency and spread. It is primarily based on the psych::alpha function, with more parsimonious output and some added functionality.

Usage

svy_make_scale(
  df,
  scale_items,
  scale_name,
  print_hist = T,
  scale_title = scale_name,
  reversed = NULL,
  r_key = NULL
)

Arguments

df

A srvyr survey object

scale_items

A characters vector containing the items for that scale (variables in df)

scale_name

Character. The name of the variable the scale should be saved as

print_hist

Logical. Should histograms of the scale and its items be printed.

scale_title

Character. Name of scale for printing. Defaults to scale_name

reversed

(optional) A characters vector containing the items that should be reverse-coded ( subset of scale_items)

r_key

(optional) Numeric. Set to the possible maximum value of the scale if the whole scale should be reversed, or to -1 to reverse the scale based on the observed maximum

Value

The survey object with the scale added as an additional variable.


LukasWallrich/rNuggets documentation built on Aug. 26, 2022, 11:03 a.m.