Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am wjakethompson on github.
  • I am wjakethompson (https://keybase.io/wjakethompson) on keybase.
  • I have a public key ASBxeGlM70OLyoJrv3_ucnr5ldTrOClVZHbjqe9HMMBglQo

To claim this, I am signing this object:

@wjakethompson
wjakethompson / hourly-weather.R
Created October 23, 2017 13:03 — forked from yeedle/hourly-weather.R
Temperature of every hour in NY since 1973
library(tidyverse)
library(R.utils)
library(glue)
library(magrittr)
library(weathermetrics)
library(padr)
library(ggExtra)
library(lubridate)
library(scales)
library(hrbrthemes)
# inspired by https://twitter.com/mbostock/status/1036391604100055040
library(tidyverse)
plot_data <- crossing(x = seq(-20, 20, 0.01), y = seq(-20, 20, 0.01)) %>%
mutate(
depth = sin(sin(x * (sin(y) - cos(x)))) - cos(cos(y * (cos(x) - sin(y))))
)
ggplot(plot_data, aes(x = x, y = y)) +
@wjakethompson
wjakethompson / priors.R
Created October 11, 2018 15:34
R code for creating plot showing the effect of different priors
library(tidyverse)
library(viridis)
set.seed(92414)
### Draw samples from prior distributions --------------------------------------
# Non-Information: N(-2, 10)
# Weakly Informative: N(-2, 2)
# Informative: N(-2, 1)
@wjakethompson
wjakethompson / ggclock.R
Last active November 15, 2018 03:48
R code for generating a ggclock
library(tidyverse)
library(ggimage)
logo <- "https://www.rstudio.com/wp-content/uploads/2014/06/RStudio-Ball.png"
minutes <- data_frame(x = 0:60, y = 1)
hours <- filter(minutes, x %% 5 == 0)
ggplot() +
geom_point(data = minutes, aes(x = x, y = y), size = 10) +
@wjakethompson
wjakethompson / emip-submission-2016.R
Created January 13, 2019 20:33
Submission for 2016 EM:IP Cover Showcase
# Note: Code and graphic have been updated since original submission
### User input -----------------------------------------------------------------
num_stu <- 20000
num_testlet <- 6
num_item <- 10
set.seed(3567)
@wjakethompson
wjakethompson / emip-submission-2017.R
Created January 13, 2019 20:38
Submission for 2017 EM:IP Cover Showcase
### Define functions -----------------------------------------------------------
logit <- function(x) {
exp(x) / (1 + exp(x))
}
comp <- function(x, y, a1 = 1, a2 = 1, d = 0, c = 0) {
lin_comb <- (a1 * x) + (a2 * y)
c + (1 - c) * logit(lin_comb - d)
}
noncomp <- function(x, y, a1 = 1, a2 = 1, d1 = 0, d2 = 0, c = 0) {
c + (1 - c) * prod(logit((a1 * x) - d1), logit((a2 * y) - d2))
library(tidyverse) # For ggplot, dplyr, and friends
library(historydata) # Historical population data
library(USAboundaries) # Historical geographic data
# remotes::install_github("ropensci/USAboundariesData") # Actual data
library(rvest) # Scrape websites
library(sf) # Plot geographic data
library(tigris) # Shift AK, HI, and PR around with shift_geometry()
library(patchwork) # For combining plots