-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
120 lines (98 loc) · 3.42 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
title: "R Ladies Global Map"
author: Priyanga Dilini Talagala, Thiyanga Talagala
date: December 12, 2019
output:
md_document:
variant: markdown_github
---
<img src="Rladiescolombo.png" align="left" height="150" />
## Where we are?
```{r setup, include=FALSE }
knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
```
```{r plot}
library(ggplot2)
library(maptools)
library(tibble)
library(tidyverse)
library(ggrepel)
library(png)
library(grid)
data(wrld_simpl)
p <- ggplot() +
geom_polygon(
data = wrld_simpl,
aes(x = long, y = lat, group = group), fill = "thistle", colour = "white"
) +
coord_cartesian(xlim = c(-180, 180), ylim = c(-90, 90)) +
scale_x_continuous(breaks = seq(-180, 180, 120)) +
scale_y_continuous(breaks = seq(-90, 90, 100))
# R-Ladies current chapters: https://github.com/rladies/starter-kit/blob/master/Current-Chapters.csv
df <- read.csv(here::here("Current-Chapters.csv"), header = TRUE) %>% as_tibble()
df$City <- as.character(df$City)
df$Country <- as.character(df$Country)
## location details of the cities : https://simplemaps.com/data/world-cities
location_df <- read.csv(here::here("worldcities.csv"), header = TRUE) %>% as_tibble()
location_df$city <- as.character(location_df$city)
location_df$country <- as.character(location_df$country)
## location details of US cities: https://simplemaps.com/data/us-cities
location_us <- read.csv(here::here("uscities.csv"), header = TRUE) %>% as_tibble()
location_us$city <- as.character(location_us$city)
location_us$country <- "USA"
d <- left_join(df, location_df, by = c("Country" = "country", "City" = "city")) %>%
select(c("Country", "City", "Status", "lat", "lng"))
d_USA <- d %>%
filter(Country == "USA") %>%
select("Country", "City", "Status") %>%
left_join(y = location_us, by = c("City" = "city")) %>%
select(c("Country", "City", "Status", "lat", "lng")) %>%
distinct(City, .keep_all = TRUE)
d_full <- bind_rows((d %>% filter(Country != "USA")), d_USA) %>%
filter(Status != "Retired on 29-09-2019") %>%
distinct(Country, City, .keep_all = TRUE)
dsl <- d_full %>% filter(Country == "Sri Lanka", City == "Colombo")
p <- p +
geom_point(
data = d_full, aes(x = lng, y = lat), color = "mediumpurple1", size
= 1
) +
geom_point(
data = dsl, aes(x = lng, y = lat), color = "mediumpurple1", size
= 1
) +
geom_text_repel(
data = dsl, aes(label = "R-Ladies Colombo", x = lng, y = lat),
box.padding = 0.35,
point.padding = 0.1,
segment.color = "grey50",
nudge_y = -20,
color = "blueviolet",
fontface=2,
) +
theme(axis.title = element_blank())
p
ggsave(here::here("R-ladiesmap.png"), width = 15, height = 7)
```
```{r addcolombocity}
pic <- readPNG("colombocity.png")
g <- rasterGrob(pic, interpolate=TRUE)
q <- p + annotation_custom(g, xmin = -Inf, xmax = Inf, ymin = -225, ymax = Inf) +
geom_point()
q
```
```{r addcode}
code <- paste("R_Ladies_Global %>% filter(Chapter == ``Colombo``, Country == ``Sri Lanka``)" )
r <- q + annotate(geom="text", x=-20, y=88, label= code,
color="black", fontface=2)
r
```
```{r twittercover}
## Change positioning for twitter coverpage
code <- paste("R_Ladies_Global %>% filter(Chapter == ``Colombo``, Country == ``Sri Lanka``)" )
r <- q + annotate(geom="text", x=-20, y=40, label= code,
color="black", fontface =2)
r
ggsave(here::here("R-ladiestwittermap.png"), width = 15, height = 7)
```
Last updated: ```r Sys.Date()```