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

Introducing regional maps

We encounter maps on a daily basis, be it for directions or to infer information regarding the distribution of data. Maps have been widely used to plot various types of data in R.

The following visualization relates to the debt to GDP ratio in the European Union. Users can hover over the visualization and get more information related to the data. The visualization is inspired by the New York Times article on the same issue.

Introducing regional maps

Getting ready

We need to install and load the googleVis package in R:

install.packages("googleVis")
library(googleVis)

How to do it…

For the purpose of this recipe, we will import the data in R using the read.csv() function. The data set comprises the debt to GDP ratio among the European Union nations during the 2003-2010 period. We can check our column headings and data using the head() function:

debt = read.csv("debt.csv", header = TRUE, sep =",")

The visualization is generated in R using the gvisGeoMap() function...