library(sjmisc)
# 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, show.cmmn.row = TRUE,
# string.cmmn = sprintf("Cronbach's α=%.2f", cronb(x)))
#
# # Compute PCA on Cope-Index, and perform a
# # reliability check on each extracted factor.
# 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, show.cmmn.row = TRUE,
# use.viewer = FALSE, title = "Item-Total-Statistic",
# string.cmmn = sprintf("Scale's overall Cronbach's α=%.2f",
# cronb(rel.df)))
# }
# }## End(Not run)
Run the code above in your browser using DataLab