June 2016
Beginner to intermediate
1783 pages
71h 22m
English
A bar chart is the simplest chart that displays the frequency of a categorical variable or the summary statistics of a numeric variable over the category of other variables. In this recipe, we will learn how we can produce a bar chart using the ggplot2 library.
Let's call the ggplotdata dataset that was created in the preceding section. We intend to produce a bar chart that will represent the mean of a numeric variable on the y axis over the category of the economic status variable on the x-axis. So, we need to prepare the summarized dataset as follows:
library(plyr) bardata <- ddply(ggplotdata,.(econ_status),summarize,meandisA=mean(disA), meandisB=mean(disB),meandisC=mean(disC),meadisD=mean(disD))
The description ...
Read now
Unlock full access