table() in R
[This article was first published on [the] joint posterior distribution, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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 their blog: [the] joint posterior distribution.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.