Stacked bars are often settled to display how data is distributed across categories with respect to other categories. Using ggplot2, stacked bar plots can be simply handled by geom_bar() function; that would require nothing more than explicitly declaring the fill parameter. To demonstrate how ggplot2, ggvis and plotly can craft simple stacked bar plots we shall use car::Salaries data frame.
Creating simple stacked bar graphs
Getting ready
The data frame is Salaries from the car package. We also need the plyr package:
> if( !require(car)){ install.packages('car')}
> if( !require(plyr)){ install.packages('plyr')}
Make sure to have the internet connection before running above code...