Skip to content

Instantly share code, notes, and snippets.

View jeffreyiacono's full-sized avatar

Jeff Iacono jeffreyiacono

  • Eight Sleep
  • San Francisco
  • X @jfi
View GitHub Profile
@jeffreyiacono
jeffreyiacono / 00-start-end-higher-lower.R
Last active July 18, 2016 03:10
Color-coded Start / End Plotting with R
library(ggplot2)
library(reshape2)
df <- data.frame(grp = 1:25, start = rnorm(25, 10, 5), end = rnorm(25, 5, 3))
df$end_higher <- df$start < df$end
mdf <- melt(df, id.vars = c("grp", "end_higher"))
names(mdf) <- c("grp", "end_higher", "category", "value")
mdf$grp <- factor(mdf$grp)
@jeffreyiacono
jeffreyiacono / 00-start-end.R
Last active July 18, 2016 03:04
Start / End Plotting with R
library(ggplot2)
library(reshape2)
# data setup
df <- data.frame(grp = 1:25, start = rnorm(25, 100, 10), end = rnorm(25, 10, 5))
# ** plotting using base plot functions
par(mfrow = c(1, 1))
rng <- range(df$start, df$end)
@jeffreyiacono
jeffreyiacono / 0_reuse_code.js
Created May 18, 2016 16:58
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@jeffreyiacono
jeffreyiacono / 00-plot-percentiles-by-boundaries.R
Last active January 21, 2016 01:08
Plot percentiles by boundaries
options(repos = c(CRAN = "http://cran.rstudio.com"))
install.packages("ggplot2")
install.packages("dplyr")
require(ggplot2)
require(dplyr)
points <- 10000
buckets <- 20
@jeffreyiacono
jeffreyiacono / keybase.md
Created May 29, 2015 10:30
keybase verification

Keybase proof

I hereby claim:

  • I am jeffreyiacono on github.
  • I am jfi (https://keybase.io/jfi) on keybase.
  • I have a public key whose fingerprint is 9313 2A1C 7607 9701 D3EF B96F 28F3 F2D8 4DE7 2229

To claim this, I am signing this object:

@jeffreyiacono
jeffreyiacono / 01-plots-with-manual-color-scale.R
Last active August 29, 2015 14:15
R plots with manual color scale
d <- rnorm(1000)
df <- data.frame(x = seq(1, length(d), by = 1), y = d)
df$zscore <- (df$y - mean(df$y, na.rm = TRUE)) / sd(df$y, na.rm = TRUE)
ggplot(df, aes(x = x, y = y, group = abs(zscore) >= 1.95)) + geom_point(aes(color = abs(zscore) >= 1.95))
ggplot(df, aes(x = x, y = y, group = abs(zscore) >= 1.95)) + geom_point(aes(color = abs(zscore) >= 1.95)) + scale_color_manual(values = c("FALSE" = "grey", "TRUE" = "red"))
@jeffreyiacono
jeffreyiacono / blocks.rb
Created November 5, 2014 05:47
fun with ruby blocks
def something a, b, &block
sum = a + b
another_private_thing = "only something can see this"
puts "I'm in something, executing code."
puts "I added #{a} + #{b} and got #{sum}"
puts "and I can access my local vars: another_private_thing = #{another_private_thing}"
yield sum, another_private_thing
@jeffreyiacono
jeffreyiacono / galton_child_parent_height.R
Last active August 29, 2015 14:05
Galton Child vs Parent height freq-sized scattersplot
library(UsingR)
library(ggplot2)
library(reshape)
data(galton)
freqData <- as.data.frame(table(galton$child, galton$parent))
names(freqData) <- c("child", "parent", "freq")
freqData$child <- as.numeric(as.character(freqData$child))
freqData$parent <- as.numeric(as.character(freqData$parent))
@jeffreyiacono
jeffreyiacono / fit-model-that-combines-predictors.R
Last active August 29, 2015 14:04
PML: combining predictors
library(ISLR)
library(ggplot2)
library(caret)
data(Wage)
# remove logwag as predicting wage, so this would be a pretty good predictor :)
Wage <- subset(Wage, select = -c(logwage))
# cross-validation data
@jeffreyiacono
jeffreyiacono / sigmoid.m
Created November 25, 2013 06:22
sigmoid in octave
x = -10:0.1:10;
plot(x, 1 ./ (1 + e .^ -x))