The table function in R is very useful, especially when working with survey data. Often you may have Likert scales for levels of agreement or satisfaction. table() quickly gives the distribution of answers, which can then be used for (bar)plots.
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).