# Data from the EUROFAMCARE sample dataset
data(efc)
# retrieve variable and value labels
varlabs <- get_label(efc)
# recveive first item of COPE-index scale
start <- which(colnames(efc) == "c82cop1")
# recveive last item of COPE-index scale
end <- which(colnames(efc) == "c90cop9")
# create data frame with COPE-index scale
x <- data.frame(efc[, c(start:end)])
colnames(x) <- varlabs[c(start:end)]
## Not run: 
# library(sjPlot)
# sjt.df(reliab_test(x), describe = FALSE, showCommentRow = TRUE,
#        commentString = sprintf("Cronbach's α=%.2f", cronb(x)))## End(Not run)
# Compute PCA on Cope-Index, and perform a
# reliability check on each extracted factor.
## Not run: 
# factors <- sjt.pca(x)$factor.index
# findex <- sort(unique(factors))
# library(sjPlot)
# for (i in 1:length(findex)) {
#  rel.df <- subset(x, select = which(factors == findex[i]))
#  if (ncol(rel.df) >= 3) {
#    sjt.df(reliab_test(rel.df), describe = FALSE, showCommentRow = TRUE,
#           useViewer = FALSE, title = "Item-Total-Statistic",
#           commentString = sprintf("Scale's overall Cronbach's α=%.2f",
#                                   cronb(rel.df)))
#    }
#  }## End(Not run)
Run the code above in your browser using DataLab