Description Usage Arguments Value Author(s) Examples
Compute scale scores exploiting regularities in the item names.
1 2 |
data |
A dataframe. |
pattern |
A list of named items. Each element of the list identifies a set of items composing a scale, through a vector of strings. Each scale is identified by a vector of strings. All items whose names include all the strings specified in the vector are included in the scale. |
recode |
Logical. Whether reverse-coded items should be recoded before estimating reliability. |
recString |
A string that identifies reverse-coded items, by default "_r". Be careful: if |
min |
The lowest point of the response scale |
max |
The highest point of the response scale |
na.rm |
Whether NAs should be removed before computing scale score |
A dataframe of scale scores
Giulio Costantini
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | library(psychTools)
data(bfi)
# bfi.keys include information on reverse-scoring. In particular, items with the string
# "-" are reverse-scored. We can exploit this information to reverse-score all items
bfi2 <- bfi
names(bfi2)[1:25] <- c("-A1", "A2", "A3", "A4", "A5",
"C1", "C2", "C3", "-C4", "-C5",
"-E1", "-E2", "E3", "E4", "E5" ,
"N1", "N2", "N3", "N4", "N5",
"O1", "-O2", "O3", "O4", "-O5")
# scale scores can be computed with function scaleScores
BFI <- scaleScores(bfi2, pattern = list(
"Openness" = c("O"),
"Conscientiousness" = c("C"),
"Extraversion" = c("E"),
"Agreeableness" = c("A"),
"Neuroticism" = c("N")),
recode = TRUE,
recString = "-",
min = 1, max = 6)
head(BFI)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.