Reader small image

You're reading from  Applied Data Visualization with R and ggplot2

Product typeBook
Published inSep 2018
Reading LevelIntermediate
Publisher
ISBN-139781789612158
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Dr. Tania Moulik
Dr. Tania Moulik
author image
Dr. Tania Moulik

Tania Moulik has a PhD in particle physics. She has worked at CERN, the European Organization for Nuclear Research, and on the Tevatron at Fermi National Accelerator Laboratory in IL, USA. She has years of programming experience in C++, Python, and R. She has also worked in the feld of big data and has worked with technologies such as grid computing. She has a passion for data analysis and would like to share her passion with others who would like to delve into the world of data analytics. She especially likes R and ggplot2 as a powerful analytics package.
Read more about Dr. Tania Moulik

Right arrow

Maps


Sometimes, we want to know the trends and behaviors of people in different countries or states. For example, we might want to see the shopping behaviors of people in different states. The maps package is useful for this purpose. In this section, we will look at how to draw and display information with maps.

 

 

Displaying Information with Maps

In this section, we'll create a map of the US and Europe that is colored according to lat, long, and group variables. Let's begin by implementing the following steps:

  1. Install the maps package using map_data to get a data frame for the different states' information, as follows:
states_map <- map_data("state")
glimpse(states_map)
## Observations: 15,537
## Variables: 6
## $ long <dbl> -87.46201, -87.48493, -87.52503, -87.53076, -87.5708...
## $ lat <dbl> 30.38968, 30.37249, 30.37249, 30.33239, 30.32665, 30...
## $ group <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
## $ order <int> 1, 2, 3, 4, 5, 6, 7, 8, 9,...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Applied Data Visualization with R and ggplot2
Published in: Sep 2018Publisher: ISBN-13: 9781789612158

Author (1)

author image
Dr. Tania Moulik

Tania Moulik has a PhD in particle physics. She has worked at CERN, the European Organization for Nuclear Research, and on the Tevatron at Fermi National Accelerator Laboratory in IL, USA. She has years of programming experience in C++, Python, and R. She has also worked in the feld of big data and has worked with technologies such as grid computing. She has a passion for data analysis and would like to share her passion with others who would like to delve into the world of data analytics. She especially likes R and ggplot2 as a powerful analytics package.
Read more about Dr. Tania Moulik