# Example using the function scores(): source("http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Software/scores.r") items = data.frame(v1 = c( 1, 1, 1, 1, 1, 1,NA), v2 = c( 2, 2, 2,NA, 2,NA,NA), v3 = c( 3, 3, 3, 3,NA,NA,NA), v4 = c( 4, 4,NA, 4,NA,NA,NA), v5 = c( 5,NA,NA,NA,NA,NA,NA)) # Create test = mean scores of v1,v3,v4, and v5: # Because fcn='mean' is default you need not specify fcn='mean'. Because 1 is # default of minvalid you will obtain valid scores for all cases with at least # 1 valid value: attach(items) cbind(items,test=scores(v1,v3,v4,v5)) detach(items) # Same as above but specifying the data frame: cbind(items,test=scores(items[,-2])) # Same as above but specify minvalid(3) so that scores are valid only if least # three values of the four variables are valid (or equivalently: at most 4-3=1 # value may be missing): cbind(items,test=scores(items[,-2],minvalid=3)) # Same as above but requesting minima instead of mean scores: cbind(items,test=scores(items[,-2],minvalid=3,fcn='min')) # Same as above but requesting maxima instead of minima: cbind(items,test=scores(items[,-2],minvalid=3,fcn='max')) # Same as above but requesting sum scores instead of maxima: cbind(items,test=scores(items[,-2],minvalid=3,fcn='sum')) # Same as above but requesting standard deviations instead of sum scores: cbind(items,test=scores(items[,-2],minvalid=3,fcn='sd')) # Same as above but requesting mean scores centered at the overall mean: cbind(items,test=scores(items[,-2],minvalid=3,score='c')) # Same as above but requesting mean scores transformed to z-scores: cbind(items,test=scores(items[,-2],minvalid=3,score='z')) # Same as above but requesting mean scores transformed to POMP scores assuming # Likert scale items with anchors ranging from 1 (minimum possible value) to 5 # (maximum possible value): cbind(items,test=scores(items[,-2],minvalid=3,score='p',minval=1,maxval=5))