(This article was first published on

**[the] joint posterior distribution**, and kindly contributed to R-bloggers)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).

To

**leave a comment**for the author, please follow the link and comment on his blog:**[the] joint posterior distribution**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...