View source: R/bruceR-stats_2_scale.R
Alpha | R Documentation |
\alpha
and McDonald's \omega
).An extension of psych::alpha()
and psych::omega()
,
reporting (1) scale statistics
(Cronbach's \alpha
and McDonald's \omega
) and
(2) item statistics
(item-rest correlation [i.e., corrected item-total correlation]
and Cronbach's \alpha
if item deleted).
Three options to specify variables:
var + items
: common and unique parts of variable names (suggested).
vars
: a character vector of variable names (suggested).
varrange
: starting and stopping positions of variables (NOT suggested).
Alpha(data, var, items, vars = NULL, varrange = NULL, rev = NULL, digits = 3)
data |
Data frame. |
var |
[Option 1]
Common part across variables: e.g., |
items |
[Option 1]
Unique part across variables: e.g., |
vars |
[Option 2]
Character vector specifying variables: e.g., |
varrange |
[Option 3]
Character string specifying positions ("start:stop") of variables: e.g., |
rev |
[Optional] Variables that need to be reversed. It can be (1) a character vector specifying the reverse-scoring variables (recommended), or (2) a numeric vector specifying the item number of reverse-scoring variables (not recommended). |
digits |
Number of decimal places of output. Defaults to |
A list of results obtained from
psych::alpha()
and psych::omega()
.
MEAN
, EFA
, CFA
# ?psych::bfi
data = psych::bfi
Alpha(data, "E", 1:5) # "E1" & "E2" should be reversed
Alpha(data, "E", 1:5, rev=1:2) # correct
Alpha(data, "E", 1:5, rev=cc("E1, E2")) # also correct
Alpha(data, vars=cc("E1, E2, E3, E4, E5"), rev=cc("E1, E2"))
Alpha(data, varrange="E1:E5", rev=cc("E1, E2"))
# using dplyr::select()
data %>% select(E1, E2, E3, E4, E5) %>%
Alpha(vars=names(.), rev=cc("E1, E2"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.