Book Image

R Data Visualization Cookbook

By : Gohil
Book Image

R Data Visualization Cookbook

By: Gohil

Overview of this book

If you are a data journalist, academician, student or freelance designer who wants to learn about data visualization, this book is for you. Basic knowledge of R programming is expected.
Table of Contents (12 chapters)
11
Index

Generating an interactive scatter plot


In the previous recipe, we studied how multivariate data can be displayed on a scatter plot. We used color as a visual cue to display information related to different presidents in the USA and how the economy performed. In this recipe, we will build on the same idea and introduce interactive scatter plots. The limitation of a static plot is that they are hard to interpret if the points overlap, and if the gridlines are not present the data may be hard to decipher as well. Interactive plots help us to overcome this limitation. In this recipe, we will plot a simple interactive scatter plot with a trend line as shown in the following screenshot:

Getting ready

We would plot an interactive scatter plot using the googleVis package in R.

How to do it…

To generate an interactive scatter plot, we will install and load the googleVis package in R. We can import the data in R using the read.csv() function:

install.packages("googleVis")
library(googleVis)
income = read...