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(ggplot2) | |
library(dplyr) | |
v_get_random_betas = Vectorize(rbeta) | |
ALPHAS = c(1, 2, 5, 1) | |
BETAS = c(5, 5, 5, 1) | |
DISTS = c("Floor", "Left of center", "Normalish", "Uniform") | |
NS = seq(10, 70, by = 5) | |
ITERS = 1e4 |
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(rvest) | |
library(tidyr) | |
library(splines) | |
library(stringr) | |
library(ggplot2) | |
library(dplyr) | |
setwd("C:/Dropbox/Projects/20160705_Calories_Per_Meal") | |
men = read_html("http://health.gov/dietaryguidelines/2015/guidelines/appendix-2/") %>% |
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(tidyverse) | |
library(gganimate) | |
NUMPLAYERS = 45 | |
ROUNDS = 5000 | |
INITWEALTH = 45 | |
#initialize the bank | |
#columns wealths of the NUMPLAYERS players | |
#rows show wealths of each of the ROUNDS ticks of the clocks |
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(tidyverse) | |
library(ggrepel) | |
library(scales) | |
setwd("C:/Dropbox/Projects/20170605_Population_Density") | |
#source https://factfinder.census.gov/bkmk/table/1.0/en/DEC/10_SF1/GCTPH1.US05PR | |
df <- read_csv("DEC_10_SF1_GCTPH1.US05PR.csv", skip = 1) | |
#give human readable column headers |
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(tidyverse) | |
library(weatherData) | |
library(viridis) | |
library(lubridate) | |
library(maps) | |
library(ggmap) | |
retList = vector('list', 10) | |
for (i in 2:6) { | |
retList[[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
--- | |
title: "Rain Per Day, Month, and Rainy Day in New York City" | |
author: "Dan Goldstein" | |
date: "August 26, 2017" | |
output: | |
html_document: default | |
pdf_document: default | |
word_document: default | |
--- | |
```{r setup, include=FALSE} |
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(stringr) | |
library(ggplot2) | |
library(dplyr) | |
library(scales) | |
library(markovchain) | |
MAXSTREAKLEN=16 | |
#H/T https://math.stackexchange.com/questions/383704/probability-of-streaks for this soln | |
get_prob = function(streaklen,sequencelen) |
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(tidyverse) | |
theme_set(theme_bw()) | |
STEPS = 251 | |
ITER = 5000 | |
#Function to get the change to X and Y corresponding | |
#to each die roll | |
get_offset = function(roll) | |
{ | |
nx = ny = NA |
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
#code by Ashton Anderson | |
library(tidyverse) | |
theme_set(theme_minimal()) | |
mt <- read.csv(url('https://gist.githubusercontent.com/ashtonanderson/cfbf51e08747f60472ee2132b0d35efb/raw/80acd2ad7c0fba4e85c053e61e9e5457137e00ee/moveno_piecetype_counts')) | |
mt <- mt %>% | |
group_by(move_number) %>% | |
mutate(tot = sum(count),frac = count/tot) |
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(tidyverse) | |
setwd("C:/Dropbox/Projects/20180822_heat_index16term") | |
heat_index16term = function(T, RH) { | |
retval = 16.923 + 1.85212 * 1e-1 * T + 5.37941 * RH - 1.00254 * 1e-1 * T * | |
RH + | |
9.41695 * 1e-3 * T ^ 2 + 7.28898 * 1e-3 * RH ^ 2 + 3.45372 * 1e-4 * | |
T ^ 2 * RH - 8.14971 * 1e-4 * T * RH ^ 2 + | |
1.02102 * 1e-5 * T ^ 2 * RH ^ 2 - 3.8646 * 1e-5 * T ^ 3 + 2.91583 * | |
1e-5 * RH ^ 3 + 1.42721 * 1e-6 * T ^ 3 * RH + |