Created
October 15, 2016 11:46
-
-
Save MilesMcBain/5aa9a2a501bcb48b5e362872cfca000f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tibble) | |
library(ggplot2) | |
library(dplyr) | |
library(ggrepel) | |
library(ggthemes) | |
stackR <- tribble( | |
~Aus.City, ~R, ~TotalVisits, ~Pop, | |
"Melbourne", "23176", "1544868", "4529496", | |
"Adelaide", "7181", "350850", "1316779", | |
"Perth", "6942", "517323", "2039193", | |
"Canberra", "4950", "201914", "424666", | |
"Gold Coast", "9", "12711", "624918", | |
"Brisbane", "10847", "753890", "2308720", | |
"Sydney", "24726", "1782976", "4920970", | |
"Newcastle", "138", "15348", "434454" | |
) | |
stackR <- | |
stackR %>% | |
mutate( R = as.numeric(R), | |
TotalVisits = as.numeric(TotalVisits), | |
Pop = as.numeric(Pop) | |
) | |
stackR <- | |
stackR %>% | |
mutate(prop_visits_2016 = TotalVisits/sum(stackR$TotalVisits), | |
prop_visits_R = R/TotalVisits, | |
norm_visits = TotalVisits/Pop, | |
norm_R = R/Pop) | |
#drob's plot | |
stackR %>% | |
ggplot(aes(x = prop_visits_2016, y = prop_visits_R, label = Aus.City)) + | |
geom_point() + | |
theme_light() + | |
geom_text_repel() + | |
ylab("% of traffic going to R questions") + | |
xlab("Total traffic to city as % of 2016 visits") + | |
ggtitle("R visitors to Stack Overflow") | |
#Population normalised plot | |
stackR %>% | |
ggplot(aes(x = norm_visits, y = norm_R, label = Aus.City)) + | |
geom_point() + | |
theme_light() + | |
geom_text_repel() + | |
ylab("R traffic normalised by population") + | |
xlab("Total traffic to city normalised by population") + | |
ggtitle("R visitors to Stack Overflow") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment