An interactive bar plot
We would like to make the bar plot interactive. The advantage of using the Google Chart API in R is the flexibility it provides in making interactive plots. The googleVis
package allows us to skip the step to export a plot from R to an illustrator and we can make presentable plots right out of R.
The bar plot functionality in R comes with various options and it is not possible to demonstrate all of the options in this recipe. We will try to explore plot options that are specific to bar plots.
In this recipe, we will learn to plot the returns data of Microsoft over a 2-year period. The data for the exercise was downloaded using Google Finance. We have calculated 1-day returns for Microsoft in MS Excel and imported the CSV in R:
Return = ((Pricet - Pricet-1)/pricet-1) *100
Readers should note that the following plot is only a part of the actual chart:
Getting ready
In order to plot a bar plot, we would install the googleVis
package.
How to do it…
We would start the recipe...