make.keys {psych}R Documentation

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


When scoring items by forming composite scales either from the raw data using score.items or from the correlation matrix using cluster.cor, it is necessary to create a keys matrix. This is just a short cut for doing so. The keys matrix is a nvar x nscales matrix of -1,0, 1 and defines the membership for each scale. Items can be specified by location or by name.


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



Number of variables items to be scored


A list of the scoring keys,one element for each scale


Typically, just the colnames of the items data matrix.


Labels for the scales can be specified here, or in the key.list


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. Make keys allows one to specify items by name or by location or a mixture of both.

To address items by name it is necessary to specify item names, either by using the item.labels value, or by putting the name of the data file or the colnames of the data file to be scored into the first (nvars) position.

If specifying by number, then nvars is the total number of items in the object to be scored, not just the number of items used.

See the examples for the various options.

Note that make.keys was revised in Sept, 2013 to allow for keying by name.



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

See Also

score.items, cluster.cor


data(attitude)  #specify the items by location
 key.list <- list(all=c(1,2,3,4,-5,6,7),
 keys <- make.keys(7,key.list,item.labels = colnames(attitude))
 #scores <- score.items(keys,attitude)
 #first create the keys by location (the conventional way)
 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)[1:25])
 #alternatively, create by a mixture of names and locations 
 keys.list <- list(agree=c("-A1","A2","A3","A4","A5"),
neuroticism=c(16:20),openness = c(21,-22,23,24,-25)) 
keys <- make.keys(bfi,keys.list) #specify the data file to be scored (bfi)
keys <- make.keys(colnames(bfi),keys.list) #specify the names of the variables to be used
#specify the number of variables to be scored and their names in all cases
keys <- make.keys(28,keys.list,colnames(bfi)) 

 scores <- score.items(keys,bfi)

[Package psych version 1.4.5 Index]
Part of the Personality Project      Take our Personality Test