Last active
December 12, 2017 20:39
-
-
Save chris-prener/e8db299364b5ffbee68b960b71bd9d55 to your computer and use it in GitHub Desktop.
SOC 4930 & SOC 5050 - Week 11 - Creating Scale Variable
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
library(dplyr) | |
# load data | |
autoData <- mpg | |
# subset to create data frame with only variables of interest for scale | |
autoSubset <- select(autoData, cyl, cty, hwy) | |
# visually inspect cronbach's alpha results | |
psych::alpha(autoSubset) | |
# re-calculate cronbach's alpha with check.keys argument | |
psych::alpha(autoSubset, check.keys = TRUE) | |
# store results of scale in object | |
alphaTest <- psych::alpha(autoSubset, check.keys = TRUE) | |
# use stored results to create new scale variable in original data frame | |
autoData <- mutate(autoData, scale = alphaTest$scores) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment