Skip to content

Instantly share code, notes, and snippets.

DL Miller dill

Block or report user

Report or block dill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dill
dill / tax.R
Last active Oct 8, 2019
NYT tax rate data
View tax.R
# Tax data from NYT article
# data scraped from https://www.nytimes.com/interactive/2019/10/06/opinion/income-tax-rate-wealthy.html
# load data scraped from SVG
tax <- readLines("taxdat.dat")
taxy <- c()
for(i in 1:length(tax)){
@dill
dill / cloudy_day.R
Last active Feb 21, 2019
☁️🎲💻
View cloudy_day.R
# generate some relaxing cloudy sky squares
#
# David Lawrence Miller (2019)
library(INLA)
library(ggplot2)
## function to simulate spatial fields
simdat <- function(n, seed, prior.range = c(5, .05),
prior.sigma = c(.05, .05)){
@dill
dill / good_modelz.R
Last active Nov 13, 2018
NBER isn't good at models
View good_modelz.R
# data digitized from https://twitter.com/nberpubs/status/1062080096549261312
# thanks @tpoi and co! https://cran.r-project.org/web/packages/digitize/index.html
# load the above data
dat <- read.csv("nber.csv")
# it's ya boi, mgcv
library(mgcv)
# fit the next stupidest model
@dill
dill / dat.csv
Last active Nov 5, 2019
deep dive into a terrible graphic (laffer curve)
View dat.csv
tax_rate tax_rev
0.07357329 -0.0567062
8.81285407 2.4505785
12.84385295 3.5807126
16.23680790 2.1860302
19.18260073 2.4643621
19.29050823 1.9514672
18.45218145 1.2480201
26.73285538 1.5886201
22.37159417 3.3657369
View frank_hats.csv
Hat Season Episode
Thick 6 9
Wet To Activate 4 3
Ho Ho Horny 2 9
Horny 3 1
Horny 3 1
Rods 1 9
Feet 6 6
Feet 6 7
Squeeze It 1 15
@dill
dill / preds.R
Created Sep 8, 2018
Calculate the average abundance estimates and uncertainty over multiple time periods
View preds.R
# average predictions
library(Distance)
library(dsm)
# download data from http://workshops.distancesampling.org/stand-intermed-2018/practicals/spermwhale.RData
load("spermwhale.RData")
# make sure we get the same results every time
set.seed(123)
@dill
dill / thingo.R
Created Sep 3, 2018
Uncertainty map animation
View thingo.R
# little animation to illustrate uncertainty in a density map
library(dsm)
library(mvtnorm)
library(ggplot2)
library(animation)
library(viridis)
library(cowplot)
set.seed(1997)
@dill
dill / contour_experiment.R
Created Jul 16, 2018
silly experiment with contours
View contour_experiment.R
###
n <- 200
add_layer <- function(coords=data.frame(x=0, y=0), layer=0){
so_rad <- seq(0, 2*pi-0.1, len=n)
if(layer==0){
lens0 <- 0.1*runif(1, 0.1, 1)
@dill
dill / figure-captions.R
Created Apr 14, 2018
knitr captions in HTML
View figure-captions.R
## this code makes figure captions work in HTML output
# adapted from http://gforge.se/2014/01/fast-track-publishing-using-knitr-part-iii/
library(knitr)
options(figure_counter = TRUE)
# Evaluate the figure caption after the chunk,
# sometimes you want to calculate stuff inside the
# chunk that you want to include in the caption and
# it is therefore useful to evaluate it afterwards.
@dill
dill / new-mac-settings.sh
Last active Feb 28, 2019
Setup a new Mac 💻
View new-mac-settings.sh
#!/usr/bin/env bash
# David L Miller
# updated 28 February 2019
# taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# https://twitter.com/chadwhitaker/status/1004441991415922688
# https://www.idownloadblog.com/2014/08/03/how-to-remove-the-shadow-window-screenshots-on-mac-os-x/
# and elsewhere
You can’t perform that action at this time.