Bar chats are very popular visualizations, most people are familiar with it; hence, they know to interpret bar charts. There is no excuse to not know how to craft this kinds of visualizations. A trick detail here is to order the bars, it may seem unimportant for some people but it makes total difference.
The trick here is to turn the discrete variable into a factor with reordered levels. This should be done with almost any visualization relying on some discrete values. It works well for ggplot2
, ggvis
and plotly
. Current recipe aims to demonstrate how to craft bars with custom order using all the three packages. Additionally it also makes a little data computation.
To achieve such goal we're about to adopt Ecdat::Journals
data set. First things first, make sure that Ecdat
is already installed:
> if(!require(Ecdat)){install.packages('Ecdat')} > if(!require(dplyr)){install.packages('dplyr')}
We also will require dplyr
package to handle some computations...