alpha_regex: alpha_regex: Streamline Reliability Analysis with Regular...

Description Usage Arguments Value Examples

View source: R/alpha_regex.R

Description

Is a wrapper for alpha from the psych package that conducts reliability analysis on scales identified through regular expressions. Defaults to returning a data frame with most of the main information generated by alpha, but more information can be requested using the robust_output option.

Usage

1
2
3
alpha_regex(data, ..., verbose_output = FALSE,
  scale_regex = "^[A-Za-z[:punct:]]*",
  item_regex = "[0-9]+$|[0-9]+r$|[0-9]+_r")

Arguments

data

A data frame that has been renamed in a way that the column names contain information about the scale and the item number.

...

Variables that share the naming convention of a subscale but should be dropped from scale calculations. These may include attention check items or raw scores for reverse coded items.

verbose_output

A logical value detailing whether all information generated by alpha should be returned. Defaults to FALSE.

scale_regex

A regular expression that is associated with the scale naming conventions. Defaults to the first capitalized or uncapitalized alphabetic characterers or punctuation.

item_regex

A regular expression that is associated with the item naming conventions. Defaults to the last numeric values, r, or _r.

Value

A data frame or list (dependent on verbose_output argument) containing reliability information from psych::alpha

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Example utlizes the bfi data that loads with the psych package
library(tidyverse)
bfi<-psych::bfi

# Several of the items need to be reverse coded.
# I do this by creating new items but retain the old columns in the complete data frame.
personality<-bfi%>%
              mutate_at(vars(A1, E1, E2, O2, O5, C4, C5),
                        .funs = list(r = function(x){7-x}))

reliability<-alpha_regex(data = personality, A1, E1, E2, O2, O5, C4, C5)

jimmyrigby94/regcleaner documentation built on March 26, 2020, 8:16 a.m.