Advertisement
Guest User

Untitled

a guest
Jul 16th, 2017
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 6.54 KB | None | 0 0
  1. require(dplyr)
  2. require(readr)
  3. require(ggplot2)
  4. require(gridExtra)
  5. require(scales)
  6.  
  7. Corp = read_csv('OECD_data/Seperated/CorpComb.csv')
  8. GaS = read_csv('OECD_data/Seperated/GaSComb.csv')
  9. Payroll = read_csv('OECD_data/Seperated/PayrollComb.csv')
  10. PersInc = read_csv('OECD_data/Seperated/PersIncComb.csv')
  11. Property = read_csv('OECD_data/Seperated/PropertyComb.csv')
  12. SocSec = read_csv('OECD_data/Seperated/SocSecComb.csv')
  13. TaxRev = read_csv('OECD_data/Seperated/TaxRevCom.csv')
  14. Wedge = read_csv('OECD_data/Seperated/Wedge.csv')
  15.  
  16. Corp_avgs <- Corp %>% group_by(Country) %>% summarise(CorpGPDmean=mean(`Corp%GDP`),CorpTaxMean = mean(`Corp%Tax`))
  17. GaS_avgs <- GaS %>% group_by(Country) %>% summarise(GaSGPDmean=mean(`GaS%GDP`),GasTaxMean = mean(`GaS%Tax`))
  18. Payroll_avgs <- Payroll %>% group_by(Country) %>% summarise(PayrollGPDmean=mean(`Payroll%GDP`),PayrollTaxMean = mean(`Payroll%Tax`))
  19. PersInc_avgs <- PersInc %>% group_by(Country) %>% summarise(PersIncGPDmean=mean(`PersInc%GDP`),PersIncTaxMean = mean(`PersInc%Tax`))
  20. Property_avgs <- Property %>% group_by(Country) %>% summarise(PropGPDmean=mean(`Prop%GDP`),PropTaxMean = mean(`Prop%Tax`))
  21. SocSec_avgs <- SocSec %>% group_by(Country) %>% summarise(SocSecGPDmean=mean(`SocSec%GDP`),SocSecTaxMean = mean(`SocSec%Tax`))
  22. TaxRev_avgs <- TaxRev %>% group_by(Country) %>% summarise(TaxRevGPDmean=mean(`TaxRev%GDP`),TaxRevPerCapMean = mean(`TaxRevPerCap`))
  23. Wedge_avgs <- Wedge %>% group_by(Country) %>% summarise(PercentLaborCostMean=mean(Wedge))
  24.  
  25. all_avgs <- inner_join(Corp_avgs,GaS_avgs)
  26. all_avgs <- inner_join(all_avgs,Payroll_avgs)
  27. all_avgs <- inner_join(all_avgs,PersInc_avgs)
  28. all_avgs <- inner_join(all_avgs,Property_avgs)
  29. all_avgs <- inner_join(all_avgs,SocSec_avgs)
  30. all_avgs <- inner_join(all_avgs,TaxRev_avgs)
  31. all_avgs <- inner_join(all_avgs,Wedge_avgs)
  32.  
  33. write_excel_csv(all_avgs,"all_averages_by_loc.csv")
  34. # Did some Excel Tweaking
  35. new_all_avgs <- read_csv('all_averages_by_loc.csv')
  36.  
  37. CorpGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$CorpGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
  38.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  39.   labs(x = 'as % of GDP', y = "")
  40. CorpTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$CorpTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
  41.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  42.   labs(x = 'as % of Total Taxation', y = "")
  43.  
  44. CorpPair <-grid.arrange(CorpGDPgg, CorpTaxgg, ncol = 2, left="Happiness Index", top = "Corporate Taxation (2013 - 2015 Averages)")
  45. ggsave("CorpPair.png", CorpPair, width = 8, height = 4)
  46.  
  47. GaSGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$GaSGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
  48.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  49.   labs(x = 'as % of GDP', y = "")
  50. GaSTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$GaSTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
  51.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  52.   labs(x = 'as % of Total Taxation', y = "")
  53.  
  54. GaSPair <-grid.arrange(GaSGDPgg, GaSTaxgg, ncol = 2, left="Happiness Index", top = "Goods And Services Taxation (2013 - 2015 Averages)")
  55. ggsave("GaSPair.png", GaSPair, width = 8, height = 4)
  56.  
  57. PayrollGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PayrollGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
  58.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  59.   labs(x = 'as % of GDP', y = "")
  60. PayrollTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PayrollTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
  61.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  62.   labs(x = 'as % of Total Taxation', y = "")
  63.  
  64. PayrollPair <-grid.arrange(PayrollGDPgg, PayrollTaxgg, ncol = 2, left="Happiness Index", top = "Payroll Taxation (2013 - 2015 Averages)")
  65. ggsave("PayrollPair.png", PayrollPair, width = 8, height = 4)
  66.  
  67. PersIncGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PersIncGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
  68.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  69.   labs(x = 'as % of GDP', y = "")
  70. PersIncTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PersIncTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
  71.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  72.   labs(x = 'as % of Total Taxation', y = "")
  73.  
  74. PersIncPair <-grid.arrange(PersIncGDPgg, PersIncTaxgg, ncol = 2, left="Happiness Index", top = "Personal Income Taxation (2013 - 2015 Averages)")
  75. ggsave("PersIncPair.png", PersIncPair, width = 8, height = 4)
  76.  
  77. PropGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PropGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
  78.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  79.   labs(x = 'as % of GDP', y = "")
  80. PropTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PropTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
  81.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  82.   labs(x = 'as % of Total Taxation', y = "")
  83.  
  84. PropPair <-grid.arrange(PropGDPgg, PropTaxgg, ncol = 2, left="Happiness Index", top = "Property Taxation (2013 - 2015 Averages)")
  85. ggsave("PropPair.png", PropPair, width = 8, height = 4)
  86.  
  87. SocSecGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$SocSecGPDmean,y = new_all_avgs$`Avg Happiness Index`)) +
  88.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  89.   labs(x = 'as % of GDP', y = "")
  90. SocSecTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$SocSecTaxMean,y = new_all_avgs$`Avg Happiness Index`)) +
  91.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  92.   labs(x = 'as % of Total Taxation', y = "")
  93.  
  94. SocSecPair <-grid.arrange(SocSecGDPgg, SocSecTaxgg, ncol = 2, left="Happiness Index", top = "Social Security Taxation (2013 - 2015 Averages)")
  95. ggsave("SocSecPair.png", SocSecPair, width = 8, height = 4)
  96.  
  97. TaxRevGDPgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$TaxRevGPDmean, y = new_all_avgs$`Avg Happiness Index`)) +
  98.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  99.   labs(x = 'as % of GDP', y = "")
  100. TaxRevTaxgg <- ggplot(new_all_avgs, aes(x = new_all_avgs$TaxRevPerCapMean, y = new_all_avgs$`Avg Happiness Index`)) +
  101.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  102.   scale_x_continuous(labels = comma) +
  103.   labs(x = 'USD Per Capita', y = "")
  104.  
  105. TaxRevPair <-grid.arrange(TaxRevGDPgg, TaxRevTaxgg, ncol = 2, left="Happiness Index", top = "Total Tax Revenue (2013 - 2015 Averages)")
  106. ggsave("TaxRevPair.png", TaxRevPair, width = 8, height = 4)
  107.  
  108. Wedgegg <- ggplot(new_all_avgs, aes(x = new_all_avgs$PercentLaborCostMean, y = new_all_avgs$`Avg Happiness Index`)) +
  109.   geom_text(aes(label=new_all_avgs$Country), size = 2) +
  110.   labs(x = '% of Labor Cost', y = "", title = "Wedge")
  111.  
  112. ggsave("Wedge.png", Wedgegg, width = 4, height = 4)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement