17.4 Graphs for categorical variables

  • barplot(table(data$variable)): Barplot for absolute frequencies
  • barplot(prop.table(table(data$variable))): Barplot for relative frequencies
  • barplot(table(data$variable), horiz=TRUE, las=1): Barplot
  • barplot(table(data$variable1, data$variable2)): Stacked barplot
  • barplot(table(data$variable1, data$variable2), beside=TRUE): Grouped barplot