Skip to content

Instantly share code, notes, and snippets.

function lmito(income, initial_value = 200, increased_value = 530,
taper_one_start = 37000, taper_two_start = 90000, taper_in_rate = 0.03,
taper_out_rate = 0.015) {
if (income < taper_one_start) {
return initial_value * -1;
}
else if (income >= taper_one_start & income <= taper_two_start) {
let tapered_in_lmito = (initial_value + (income - taper_one_start) * taper_in_rate);
if (tapered_in_lmito < increased_value) {
return tapered_in_lmito * -1;
#!/usr/local/bin/python3
import pandas as pd
import glob
import os
import sys
input_path = sys.argv[1]
output_file = sys.argv[2]
all_workbooks = glob.glob(os.path.join(input_path,'*.xls*'))
df_names = []
for i in all_workbooks:
medicare_levy <- function(income, rate = .02, taper_threshold_lower = 21335, taper_threshold_upper = 26668) {
if (income < taper_threshold_lower) {
# People earning below the low income threshold pay no tax
return(0)
} else if (income >= taper_threshold_lower & income <= taper_threshold_upper) {
# People earning income that is between the taper thresholds pay 10 cents for each dollar over the low income threshold
return((income - taper_threshold_lower) * .1)
} else {
# People above the upper taper threshold pay the standard medicare levy
return(income * rate)
medicare_levy <- function(income, rate) {
income * rate
}
install.packages(c('devtools', 'tidyverse'))
devtools::install_github('thmcmahon/ozTaxData')
@thmcmahon
thmcmahon / medicare_levy.R
Last active June 6, 2017 02:33
Simple version of the medicare levy calculator
medicare_levy <- function(income) {
income * .02
}
@thmcmahon
thmcmahon / lumar.R
Created January 30, 2016 07:50
Interpolation, makes it happen.
library(zoo)
path <- "~/Desktop/Total Deaths - Assault - All Ages _ tom.csv"
df <- read.csv(path, na.strings = "...", skip = 1)
# transpose the dataframe (flip it)
df <- setNames(data.frame(t(df[,-1])), df[,1])
# This just makes the names prettier
names(df) <- gsub("^ ", "", gsub("\\d", "", names(df)))
# Falkland Islands only has one value so there's nothing to interpolate
# so we'll set them all to 0
library(dplyr)
data(iris)
str(iris['Sepal.Length'])
'data.frame': 150 obs. of 1 variable:
$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
str(iris[,'Sepal.Length'])
num [1:150] 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><link rel="shortcut icon" href="https://ssl.gstatic.com/docs/spreadsheets/forms/favicon_jfk2.png" type="image/x-icon">
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=10; chrome=1;">
<meta name="fragment" content="!">
<base target="_blank">
<link rel="stylesheet" type="text/css" href="">
<link href='/static/forms/client/css/3377844631-formview_embedded_ltr.css' type='text/css' rel='stylesheet'>
<style type="text/css">