Book Image

R Data Visualization Cookbook

Book Image

R Data Visualization Cookbook

Overview of this book

Table of Contents (17 chapters)
R Data Visualization Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
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.

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 and the same is displayed in a browser...