However, especially with large scales (10 point scale) some answers may stay unused. Therefore I thought it would be nice to have a table function which returns "0" for unused categories. I tried to implement this in the table2() function. I works just like table(), there is only one additional argument "classs" which is the scale (1:10 for a 10-point Likert scale).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table2=function(data, classs) { | |
nclass=length(classs) | |
vec = rep(0,nclass) | |
names(vec)=classs | |
tdata=table(data) | |
vec[names(tdata)]=as.numeric(tdata) | |
return(vec) | |
} |
Keine Kommentare:
Kommentar veröffentlichen