Skip to content

Instantly share code, notes, and snippets.

@edwindj
Last active July 29, 2018 20:33
Show Gist options
  • Save edwindj/0b6e90ce8a2f0edc07e62a46df93dd3a to your computer and use it in GitHub Desktop.
Save edwindj/0b6e90ce8a2f0edc07e62a46df93dd3a to your computer and use it in GitHub Desktop.
countries Freq
Austria 3
Canada 2
Denmark 1
France 2
Germany 2
Guatemala 1
India 1
Indonesia 1
Ireland 1
Italy 2
Japan 4
Latvia 1
Luxembourg 1
Malayesia 1
Morocco 1
Netherlands 10
Nigeria 1
Poland 1
Portugal 1
Romania 2
Romania and Spain 1
Scotland 2
Serbia 1
Slovenia 1
South Africa 1
Spain 1
Sweden 1
Switzerland 1
Turkey 2
UK 7
USA 4
library(dplyr)
library(tmap)
library(sf)
world <- st_read("https://cartomap.github.io/world/wgs84/countries.geojson") %>%
st_transform("+proj=robin") %>%
mutate(name_en = as.character(name_en))
world$name_en[world$id == "NL"] <- "Netherlands"
uros_countries <- read.csv("uRos_countries.csv", stringsAsFactors = FALSE) %>%
mutate( countries = sub("Malayesia", "Malaysia", countries)
, countries = sub("UK", "United Kingdom", countries)
, countries = sub("USA", "United states of america", countries)
)
world$uros <- world$name_en %in% uros_countries$countries
png("uros_countries.png", width=1024, height = 660)
par(mai = c(0,0,0,0))
tm_shape(world) + tm_fill("#eeeeee", frame=F) +
tm_borders("white", lwd=0.5) +
tm_shape(world[world$uros,]) + tm_fill("#00a1cd") + tm_layout(frame=F) +
tm_borders("white", lwd=0.5)
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment