Diagrams for categorical data

Barplots

Simulate data

dice
 1  2  3  4  5  6 
19 15 18 11 16 21 

Simple barplot

plot of chunk rerDiagCategorical01
plot of chunk rerDiagCategorical01

Barplots for contingency tables of two variables

Stacked barplot

        1 2  3 4 5  6
first   9 8 11 6 9  7
second 10 7  7 5 7 14
plot of chunk rerDiagCategorical02
plot of chunk rerDiagCategorical02

Grouped barplot

plot of chunk rerDiagCategorical03
plot of chunk rerDiagCategorical03

Spineplot

plot of chunk rerDiagCategorical04
plot of chunk rerDiagCategorical04

Mosaic-plot

plot of chunk rerDiagCategorical05
plot of chunk rerDiagCategorical05

Pie-chart

Think hard about better alternatives, maybe a bar chart.

plot of chunk rerDiagCategorical06
plot of chunk rerDiagCategorical06

Conditional density plot

plot of chunk rerDiagCategorical08
plot of chunk rerDiagCategorical08

Useful packages

More plot types for categorical data are available in packages vcd and vcdExtra.

Get the article source from GitHub

R markdown - markdown - R code - all posts