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
library(data.table) | |
library(magrittr) | |
library(grattan) | |
library(SampleFile1415) | |
library(taxstats) | |
library(hutils) | |
library(scales) | |
tax2014 <- copy(sample_file_1415) %>% apply_super_caps_and_div293() |
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
library(magrittr) | |
library(grattan) | |
library(data.table) | |
library(SampleFile1415) | |
as.data.table(sample_file_1415) %>% | |
.[, tax_noCGT := Taxable_Income + Net_CG_amt] %>% | |
.[, tax := income_tax(Taxable_Income, "2014-15", .dots.ATO = sample_file_1415)] %>% | |
.[, tax_new := income_tax(tax_noCGT, "2014-15", .dots.ATO = sample_file_1415)] %>% | |
.[, .(tot = round(50 * sum(tax_new - tax) / 1e9, 1))] |
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
#' Quickly count the number of files in a directory | |
number_of_files <- function(dir, filetype = "*.*") { | |
if (.Platform$OS.type == "windows" && | |
nzchar(Sys.which("powershell"))) { | |
current_wd <- getwd() | |
on.exit(setwd(current_wd)) | |
setwd(dir) | |
result <- system2("powershell", |
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
paste("gswin64 -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer", | |
"-dNOPAUSE -dQUIET -dBATCH", "-sOutputFile=output.pdf", | |
"report-cover-energy-nem-latex.pdf") |
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
parse2 <- function(x) { | |
# x <- "ab{c{f}}d{e}f{g}h{ij{{k}}}lm" | |
x_split <- unlist(strsplit(x, "", fixed = TRUE)) | |
tex_group <- cumsum(x_split == "{") - cumsum(x_split == "}") | |
max_tex_group <- max(tex_group) | |
out <- setDT(list(char = x_split, tex_group = tex_group)) | |
out[, I := .I] | |
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
library(grattanCharts) # devtools::install_github('hughparsonage/grattanCharts') | |
library(dplyr) | |
library(httr) | |
library(tidyr) | |
library(readxl) | |
library(scales) | |
library(ggplot2) | |
library(data.table) | |
library(lubridate) | |
library(hutils) |
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
library(data.table) | |
library(hildaData) | |
library(magrittr) | |
library(grattanCharts) | |
library(ggplot2) | |
#' @source acid package (but it's chock full of unnecessary dependencies) | |
weighted_gini <- function (x, w = NULL) { | |
if (is.null(w)) | |
w <- rep(1, length(x)) |
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
formalCoverage <- function(fn) { | |
formalz <<- formals(fn) | |
bod <<- as.character(body(fn)) | |
formal_present <- function(formal) { | |
formal_dots_escaped <<- gsub(".", "\\.", formal, fixed = TRUE) | |
any(grepl(pattern = paste0("(?:\\b|\\s)", formal_dots_escaped, "(?:\\b|\\s)"), | |
x = bod, | |
perl = TRUE)) |
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
if (requireNamespace("bomrang", quietly = TRUE)) { | |
library(data.table) | |
library(bomrang) # devtools::install_github('ToowoombaTrio/bomrang') | |
`_nrst_stn_to_me` <- as.numeric(jsonlite::fromJSON("http://ip-api.com/json")[c("lat", "lon")]) | |
weather_here <- function() { | |
bomrang::get_current_weather(latlon = `_nrst_stn_to_me`, as.data.table = TRUE) %>% | |
.[, .(local_date_time, weather, rel_hum, apparent_t, air_temp, wind_dir, wind_spd_kt, gust_kt)] %>% | |
head | |
} |
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
library(testthat) | |
library(dplyr) | |
library(dtplyr) | |
library(data.table) | |
library(hildaData) | |
library(hildaExtra) | |
library(sih.hilda.1314) | |
library(taxstats) | |
library(magrittr) |