Created
April 13, 2020 04:40
-
-
Save thoughtfulbloke/6575cdab1c52161b52e280d82a377c7f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# https://www.mbie.govt.nz/immigration-and-tourism/tourism-research-and-data/tourism-data-releases/monthly-regional-tourism-estimates/regional-tourism-estimates/regional-tourism-estimates-key-pivot-table/ | |
# Regional Tourism Estimates key pivot table | |
library(readxl) | |
library(tidyr) | |
library(dplyr) | |
library(ggplot2) | |
library(forcats) | |
tourism <- read_excel("rte-pivot-table-ye-march-2015.xlsx", sheet="Database") | |
TA_tour <- tourism %>% filter(YEMar == 2015) %>% | |
group_by(Territorial_Authority) %>% | |
summarise(domestic = sum(Spend * (Type == "Domestic")), | |
international = sum(Spend * (Type == "International"))) %>% | |
ungroup() %>% | |
mutate(Territorial_Authority = gsub("Wanganui", "Whanganui", Territorial_Authority)) | |
# MBIE | |
# Modelled Territorial Authority Gross Domestic Product | |
# 2019 release to march 2018 | |
# https://www.mbie.govt.nz/business-and-employment/economic-development/regional-economic-development/modelled-territorial-authority-gross-domestic-product/2019-release/ | |
GDP <- read_excel("modelled-territorial-authority-gdp-release-2019.xlsx", sheet="data download") | |
combined <- GDP %>% filter(AreaType=="TA",RGDP_industry=="Total GDP", Year==2018) %>% | |
select(Area, `GDP($m)`) %>% rename(Territorial_Authority = Area, gdp=`GDP($m)`) %>% | |
inner_join(TA_tour, by = "Territorial_Authority") | |
g1 <- combined %>% mutate(vulnerablity_percent = 100 * international/gdp, | |
Territorial_Authority = fct_reorder(Territorial_Authority, vulnerablity_percent)) %>% | |
arrange(Territorial_Authority) %>% | |
ggplot(aes(x=Territorial_Authority, y=vulnerablity_percent)) + geom_col() + coord_flip() + theme_minimal() + ggtitle("International vulnerability") + ylim(0,70) | |
g1 | |
g2 <- combined %>% mutate(vulnerablity_percent = 100 * domestic/gdp, | |
Territorial_Authority = fct_reorder(Territorial_Authority, vulnerablity_percent)) %>% | |
arrange(Territorial_Authority) %>% | |
ggplot(aes(x=Territorial_Authority, y=vulnerablity_percent)) + geom_col() + coord_flip() + theme_minimal() + ggtitle("Domestic vulnerability")+ylim(0,70) | |
g2 | |
g3 <- combined %>% mutate(vulnerablity_percent = 100 * (domestic + international)/gdp, | |
Territorial_Authority = fct_reorder(Territorial_Authority, vulnerablity_percent)) %>% | |
arrange(Territorial_Authority) %>% | |
ggplot(aes(x=Territorial_Authority, y=vulnerablity_percent)) + geom_col() + coord_flip() + theme_minimal() + ggtitle("Total vulnerability") +ylim(0,70) | |
g3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment