Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require(dplyr)
- require(readr)
- require(ggplot2)
- require(gridExtra)
- require(scales)
- Corp = read_csv('OECD_data/Seperated/CorpComb.csv')
- GaS = read_csv('OECD_data/Seperated/GaSComb.csv')
- Payroll = read_csv('OECD_data/Seperated/PayrollComb.csv')
- PersInc = read_csv('OECD_data/Seperated/PersIncComb.csv')
- Property = read_csv('OECD_data/Seperated/PropertyComb.csv')
- SocSec = read_csv('OECD_data/Seperated/SocSecComb.csv')
- TaxRev = read_csv('OECD_data/Seperated/TaxRevCom.csv')
- Wedge = read_csv('OECD_data/Seperated/Wedge.csv')
- Corp_avgs <- Corp %>% group_by(Country) %>% summarise(CorpGPDmean=mean(`Corp%GDP`),CorpTaxMean = mean(`Corp%Tax`))
- GaS_avgs <- GaS %>% group_by(Country) %>% summarise(GaSGPDmean=mean(`GaS%GDP`),GasTaxMean = mean(`GaS%Tax`))
- Payroll_avgs <- Payroll %>% group_by(Country) %>% summarise(PayrollGPDmean=mean(`Payroll%GDP`),PayrollTaxMean = mean(`Payroll%Tax`))
- PersInc_avgs <- PersInc %>% group_by(Country) %>% summarise(PersIncGPDmean=mean(`PersInc%GDP`),PersIncTaxMean = mean(`PersInc%Tax`))
- Property_avgs <- Property %>% group_by(Country) %>% summarise(PropGPDmean=mean(`Prop%GDP`),PropTaxMean = mean(`Prop%Tax`))
- SocSec_avgs <- SocSec %>% group_by(Country) %>% summarise(SocSecGPDmean=mean(`SocSec%GDP`),SocSecTaxMean = mean(`SocSec%Tax`))
- TaxRev_avgs <- TaxRev %>% group_by(Country) %>% summarise(TaxRevGPDmean=mean(`TaxRev%GDP`),TaxRevPerCapMean = mean(`TaxRevPerCap`))
- Wedge_avgs <- Wedge %>% group_by(Country) %>% summarise(PercentLaborCostMean=mean(Wedge))
- all_avgs <- inner_join(Corp_avgs,GaS_avgs)
- all_avgs <- inner_join(all_avgs,Payroll_avgs)
- all_avgs <- inner_join(all_avgs,PersInc_avgs)
- all_avgs <- inner_join(all_avgs,Property_avgs)
- all_avgs <- inner_join(all_avgs,SocSec_avgs)
- all_avgs <- inner_join(all_avgs,TaxRev_avgs)
- all_avgs <- inner_join(all_avgs,Wedge_avgs)
- write_excel_csv(all_avgs,"all_averages_by_loc.csv")
- # Did some Excel Tweaking
- new_all_avgs <- read_csv('all_averages_by_loc.csv')
- CorpGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$CorpGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- CorpTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$CorpTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of Total Taxation', y = "")
- CorpPair <-grid.arrange(CorpGDPgg, CorpTaxgg, ncol = 2, left="Happiness Index", top = "Corporate Taxation (2013 - 2015 Averages)")
- ggsave("CorpPair.png", CorpPair, width = 8, height = 4)
- GaSGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$GaSGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- GaSTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$GaSTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of Total Taxation', y = "")
- GaSPair <-grid.arrange(GaSGDPgg, GaSTaxgg, ncol = 2, left="Happiness Index", top = "Goods And Services Taxation (2013 - 2015 Averages)")
- ggsave("GaSPair.png", GaSPair, width = 8, height = 4)
- PayrollGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PayrollGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- PayrollTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PayrollTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of Total Taxation', y = "")
- PayrollPair <-grid.arrange(PayrollGDPgg, PayrollTaxgg, ncol = 2, left="Happiness Index", top = "Payroll Taxation (2013 - 2015 Averages)")
- ggsave("PayrollPair.png", PayrollPair, width = 8, height = 4)
- PersIncGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PersIncGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- PersIncTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PersIncTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of Total Taxation', y = "")
- PersIncPair <-grid.arrange(PersIncGDPgg, PersIncTaxgg, ncol = 2, left="Happiness Index", top = "Personal Income Taxation (2013 - 2015 Averages)")
- ggsave("PersIncPair.png", PersIncPair, width = 8, height = 4)
- PropGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PropGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- PropTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PropTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of Total Taxation', y = "")
- PropPair <-grid.arrange(PropGDPgg, PropTaxgg, ncol = 2, left="Happiness Index", top = "Property Taxation (2013 - 2015 Averages)")
- ggsave("PropPair.png", PropPair, width = 8, height = 4)
- SocSecGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$SocSecGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- SocSecTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$SocSecTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of Total Taxation', y = "")
- SocSecPair <-grid.arrange(SocSecGDPgg, SocSecTaxgg, ncol = 2, left="Happiness Index", top = "Social Security Taxation (2013 - 2015 Averages)")
- ggsave("SocSecPair.png", SocSecPair, width = 8, height = 4)
- TaxRevGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$TaxRevGPDmean, y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = 'as % of GDP', y = "")
- TaxRevTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$TaxRevPerCapMean, y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- scale_x_continuous(labels = comma) +
- labs(x = 'USD Per Capita', y = "")
- TaxRevPair <-grid.arrange(TaxRevGDPgg, TaxRevTaxgg, ncol = 2, left="Happiness Index", top = "Total Tax Revenue (2013 - 2015 Averages)")
- ggsave("TaxRevPair.png", TaxRevPair, width = 8, height = 4)
- Wedgegg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PercentLaborCostMean, y = new_all_avgs$`Avg Happiness Index`)) +
- geom_text(aes(label=new_all_avgs$Country), size = 2) +
- labs(x = '% of Labor Cost', y = "", title = "Wedge")
- ggsave("Wedge.png", Wedgegg, width = 4, height = 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement