vignettes/long-vignettes/vignettes/long-vignettes/issues/166.Rmd
166.Rmd
library(data.table)
library(SampleFile1516)
library(SampleFile1415)
library(grattan)
library(hutils)
library(magrittr)
library(ggplot2)
library(grattanCharts)
##
## Attaching package: 'grattanCharts'
## The following object is masked from 'package:datasets':
##
## Orange
s1516[, tax := income_tax(Taxable_Income, "2015-16", .dots.ATO = copy(s1516))]
s1516[, tax_no_frnk := tax + (tax <= Dividends_franking_cr_amt) * Dividends_franking_cr_amt]
s1516[, isAffected := tax_no_frnk > tax]
s1516[, delta := tax_no_frnk - tax]
s1415[, tax := income_tax(Taxable_Income, "2014-15", .dots.ATO = copy(s1415))]
s1415[, tax_no_frnk := tax + (tax <= Dividends_franking_cr_amt) * Dividends_franking_cr_amt]
s1415[, isAffected := tax_no_frnk > tax]
s1415[, delta := tax_no_frnk - tax]
## Sex isAffected
## 1: Female 0.08014375
## 2: Male 0.05970204
## Sex isAffected
## 1: Female 0.08082132
## 2: Male 0.05997154
## [1] 0.5582023
## [1] 0.6792155
# Average sizes by gender
s1516[, .(avgAffected = mean(Dividends_franking_cr_amt)), keyby = "Gender"]
## Gender avgAffected
## 1: 0 718.6282
## 2: 1 632.0685
s1516[Dividends_franking_cr_amt > 0, .(avgAffected = mean(Dividends_franking_cr_amt)), keyby = "Gender"]
## Gender avgAffected
## 1: 0 3447.503
## 2: 1 2888.947
# Average size of dividends credit among those affected
s1516[(isAffected), .(avgAffected = mean(Dividends_franking_cr_amt)), keyby = "Gender"]
## Gender avgAffected
## 1: 0 2636.391
## 2: 1 2306.922
## Sex avgDelta
## 1: Female 186.4485
## 2: Male 158.1084
# Average change in tax if Div_cr non-refundable -- among those affected
s1516[(isAffected), .(avgDelta = mean(delta)), keyby = "Sex"]
## Sex avgDelta
## 1: Female 2306.922
## 2: Male 2636.391