library(tidyverse)
tuesdata <- tidytuesdayR::tt_load(2020, week = 50)
##
## Downloading file 1 of 1: `women.csv`
women <- tuesdata$women
women
## # A tibble: 100 x 6
## name img category country role description
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Unsung … https://ichef.bb… All Worldwi… Making a… "In an extraordinary…
## 2 Loza Ab… https://ichef.bb… Leadersh… Ethiopia Football… "Loza Abera Geinore …
## 3 Houda A… https://ichef.bb… Creativi… Morocco Rapper "Houda Abouz, aka Kh…
## 4 Christi… https://ichef.bb… Leadersh… Netherl… Campaign… "Christina was behin…
## 5 Yvonne … https://ichef.bb… Leadersh… Sierra … Mayor "Mayor Yvonne Aki-Sa…
## 6 Rina Ak… https://ichef.bb… Knowledge Banglad… Former s… "During the pandemic…
## 7 Sarah A… https://ichef.bb… Knowledge UAE Minister… "Her Excellency Sara…
## 8 Waad a… https://ichef.bb… Creativi… Syria Film-mak… "Waad al-Kateab is a…
## 9 Adriana… https://ichef.bb… Knowledge Italy Patholog… "Adriana Albini is h…
## 10 Ubah Ali https://ichef.bb… Leadersh… Somalil… FGM educ… "Ubah Ali is a co-fo…
## # … with 90 more rows
women %>%
count(category)
## # A tibble: 5 x 2
## category n
## <chr> <int>
## 1 All 1
## 2 Creativity 21
## 3 Identity 17
## 4 Knowledge 32
## 5 Leadership 29
women <- women %>%
filter(name != "Unsung hero") #delete Unsung hero (woman with no name/country etc.)
women
## # A tibble: 99 x 6
## name img category country role description
## <chr> <chr> <chr> <chr> <chr> <chr>
## 1 Loza Ab… https://ichef.bb… Leadersh… Ethiopia Football… "Loza Abera Geinore …
## 2 Houda A… https://ichef.bb… Creativi… Morocco Rapper "Houda Abouz, aka Kh…
## 3 Christi… https://ichef.bb… Leadersh… Netherl… Campaign… "Christina was behin…
## 4 Yvonne … https://ichef.bb… Leadersh… Sierra … Mayor "Mayor Yvonne Aki-Sa…
## 5 Rina Ak… https://ichef.bb… Knowledge Banglad… Former s… "During the pandemic…
## 6 Sarah A… https://ichef.bb… Knowledge UAE Minister… "Her Excellency Sara…
## 7 Waad a… https://ichef.bb… Creativi… Syria Film-mak… "Waad al-Kateab is a…
## 8 Adriana… https://ichef.bb… Knowledge Italy Patholog… "Adriana Albini is h…
## 9 Ubah Ali https://ichef.bb… Leadersh… Somalil… FGM educ… "Ubah Ali is a co-fo…
## 10 Nisreen… https://ichef.bb… Knowledge Iraq/UK Public h… "Nisreen is a public…
## # … with 89 more rows
women %>%
count(category)
## # A tibble: 4 x 2
## category n
## <chr> <int>
## 1 Creativity 21
## 2 Identity 17
## 3 Knowledge 32
## 4 Leadership 29
library(tidygeocoder)
women <- women %>%
tidygeocoder::geocode(address = country, method = "osm")
leaflet
interactive mapLoad {leaflet}
package:
library(leaflet)
Select palette “Set1” from {RColorBrewer}
:
pal <- colorFactor(palette = "Set1", women$category)
Customize pop-up text with {glue}
library(glue)
women <- women %>%
mutate(description_html = glue('<figure>
<img src={img} width=120>
<figcaption>
<b>{name}</b> ({country}) <br>
Category: <b>{category}</b> <br>
Role/profession: <b>{role}</b>
</figcaption>
</figure>'))
Creating leaflet
object:
# simple_leaflet <- leaflet()
# str(simple_leaflet) #looks like a list with classes "leaflet", "htmlwidget"
leaflet(data = women) %>%
addProviderTiles(providers$Stamen.Terrain) %>%
addCircleMarkers(lng = ~long, lat = ~lat, clusterOptions = markerClusterOptions(),
color = ~pal(category), opacity = 0.9, fillOpacity = 0.6, radius = 12,
popup = ~description_html) %>%
addLegend("topright", pal = pal, values = ~category,
title = "Category",
opacity = 1)