Contingency Tables in R: Insights from a PhD

Contingency Tables in R: Insights from a PhD
Key points A contingency table is a way to show how often different categories of two or more variables occur together.  You can make a two-way contingency table in R with the table() function. You can also add the totals and percentages of each category with the addmargins() and prop.table() functions. You can make a mosaic plot in R with the plot() function. A mosaic plot is a picture of a contingency table that shows the size and color of each category.  Make a three-way contingency table in R with the ftable() function. A three-way contingency table is a way to show how three variables are related to each other.  You can test if two variables are independent or not in R with the chisq.test() function. It compares how often each category actually occurs with how often it would occur by chance.  You can measure how strong and in what direction the association between two variables is in R with the cor() function. It gives you a number between 0 and 1 that tells you how much one variable c…

About the author

Ph.D. Scholar | Certified Data Analyst | Blogger | Completed 5000+ data projects | Passionate about unravelling insights through data.

Post a Comment