Learn R Programming

psych (version 1.0-77)

make.keys: Create a keys matrix for use by score.items or cluster.cor

Description

When scoring items by forming composite scales either from the raw data using score.items or from the correlatio matrix using cluster.cor, it is necessary to create a keys matrix. This is just a short cut for doing so.

Usage

make.keys(nvars, keys.list, key.labels = NULL, item.labels = NULL)

Arguments

nvars
Number of variables items to be scored
keys.list
A list of the scoring keys,one element for each scale
key.labels
Labels for the scales can be specified here, or in the key.list
item.labels
Typically, just the colnames of the items data matrix.

Value

  • keysa nvars x nkeys matrix of -1, 0, or 1s describing how to score each scale. nkeys is the length of the keys.list

Details

There are two ways to create keys for the score.items function. One is to laboriously do it in a spreadsheet and then copy them into R. The other is to just specify them by item number in a list.

See Also

score.items, cluster.cor, ~~~

Examples

Run this code
data(attitude)
 key.list <- list(all=c(1,2,3,4,-5,6,7),
                  first=c(1,2,3),
                  last=c(4,5,6,7))
 keys <- make.keys(7,key.list,item.labels = colnames(attitude))
 keys
 
 scores <- score.items(keys,attitude,short=TRUE)
 scores
 
 data(bfi)
 keys.list <- list(agree=c(-1,2:5),conscientious=c(6:8,-9,-10),extraversion=c(-11,-12,13:15),neuroticism=c(16:20),openness = c(21,-22,23,24,-25))
 keys <- make.keys(25,keys.list,item.labels=colnames(bfi))
 scores <- score.items(keys,bfi,short=TRUE)
 scores

Run the code above in your browser using DataLab