In some situations, we need to produce bar charts for more than one numeric variable over the category of other variables. In this recipe, we will learn how we can produce a bar chart with more than one numeric variable.
To produce multiple bar charts, we will use the same
ggplotdata source data, but we need some preprocessing to create the input data for the plot. Firstly, we will summarize the source data and calculate the mean for each numeric variable for each unique value of economic status variable:
library(plyr) bardata <- ddply(ggplotdata,.(econ_status),summarize,meandisA=mean(disA), meandisB=mean(disB),meandisC=mean(disC),meandisD=mean(disD))
ggplot2, we need to transform the data in a layout ...