Skip to content

Instantly share code, notes, and snippets.

View hilaryparker's full-sized avatar

Hilary Parker hilaryparker

View GitHub Profile
ip-10-8-0-222:tech-site hilaryparker$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Rubygems 2.0.14.1 is not threadsafe, so your gems will be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
Using i18n 0.7.0
Using json 1.8.3
Using minitest 5.9.0
Using thread_safe 0.3.5
Using addressable 2.4.0
@hilaryparker
hilaryparker / proportions.R
Last active July 16, 2016 01:58
teasing apart statistical tests done with various proportion test approaches
## prop.test gives pooled 2-sample proportion result
## glm w/ binomial family gives unpooled 2-sample proportion result
## lm and glm w/ gaussian family give unknown result
library(dplyr)
library(broom)
set.seed(12345)
## set up dataframe -------------------------
n_A <- 5000
@hilaryparker
hilaryparker / bootstrap_boom.R
Created December 29, 2015 23:19
get bootstrap histogram quickly
library(dplyr)
library(broom)
library(ggplot2)
dat <- data.frame(x = runif(50000)) %>% tbl_df()
res <- dat %>% bootstrap(100) %>% do(tidy(lm(x ~ 1, .)))
ggplot(res, aes(x = estimate)) + geom_histogram()
@hilaryparker
hilaryparker / hilary.R
Created April 12, 2015 23:58
make a quick Hilary/Hillary graph
library(babynames)
library(dplyr)
library(ggplot2)
babynames <- babynames %>% tbl_df()
babynames %>%
filter(name == "Hilary" | name == "Hillary") %>%
filter(year >= 1950, sex == "F") %>%
ggplot(aes(x = year, y = prop, group = name, color = name)) + geom_line()
@hilaryparker
hilaryparker / gist:5a8b4d14622821927576
Created March 27, 2015 21:15
.Rprofile w/ cat error message
# .Rprofile -- commands to execute at the beginning of each R session
#
# You can use this file to load packages, set options, etc.
#
# NOTE: changes in this file won't be reflected until after you quit
# and start a new session
#
require(ProjectTemplate)
@hilaryparker
hilaryparker / results.R
Created August 25, 2014 18:23
how I make results dataframes
results <- tbl_df(as.data.frame(matrix(nrow=length(users), ncol=2)))
# what I would love
create_tbl_df(nrow=length(users), ncol=2)
@hilaryparker
hilaryparker / sunrise.set.R
Created June 2, 2014 01:19
sunrise.set.R function
sunrise.set <- function (lat, long, date, timezone = "UTC", num.days = 1)
{
lat.long <- matrix(c(long, lat), nrow = 1)
day <- as.POSIXct(date, tz = timezone)
sequence <- seq(from = day, length.out = num.days, by = "days")
sunrise <- sunriset(lat.long, sequence, direction = "sunrise",
POSIXct = TRUE)
sunset <- sunriset(lat.long, sequence, direction = "sunset",
POSIXct = TRUE)
ss <- data.frame(sunrise, sunset)