Idea

Nathan Yau‘s book, Visualize This, is a book for learning by reading and doing. The theory and concepts explained are stated clearly and colloquially, as if it were a great master class, in the same way that the examples are explained step by step, and detailing the reason behind each line of code.

I liked several graphs, their practical application and the way they allow you to visualize the data. I have already included another example (inspired by the book) corresponding to the use of a heatmap.

In this case, I was inspiring by the example for the case shown in the section Map Countries from Chapter 8: Visualizing spatial relationship about how to process countries using SVG map, but instead of using SVG Map I rather prefer to use leaflet library.

﻿﻿﻿﻿﻿﻿﻿﻿﻿﻿

Technical implementation

I would like to say that using the leaflet package is so easy and straight forward that it is really valuable each minute that you need at the beginning to discover how to implement it into your projects.

If I had to separate the code in parts, I would say that two parts it is the best division:

1. to get the data

2. to create the map

How to get the data

## get data for map json_api <- "https://raw.githubusercontent.com/PublicaMundi/MappingAPI/master/data/geojson/countries.geojson" mundo <- geojson_read(json_api, what = "sp") ## get info about percentage of women in parliament url_wom <- 'https://raw.githubusercontent.com/frm1789/women_parliament/master/data_women_parliament_2017.csv' df_wom <- read_csv(url(url_wom)) ## complete mundo@data w/info about women in parliament mundo@data <- left_join(mundo@data, df_wom, by = c("id"="country_code"))

How to get the map