y <- attitude #from the datasets package
keys <- matrix(c(rep(1,7),rep(1,4),rep(0,7),rep(-1,3)),ncol=3)
colnames(keys) <- c("first","second","third")
x <- score.items(keys,y)
x
#
#see also the example including the bfi data set
data(bfi)
describe(bfi)
keys <- matrix(c(-1,1,1,1,1,rep(0,25),1,1,1,-1,-1,rep(0,25),-1,-1,1,1,1,rep(0,25),1,1,1,1,1,rep(0,25),1,-1,1,1,-1),ncol=5)
rownames(keys) <- colnames(bfi)
colnames(keys) <- c("Agreeable","Conscientious","Extravert","Neurotic","Open")
score.items(keys,bfi,short=TRUE)
Run the code above in your browser using DataCamp Workspace