Skip to content

Instantly share code, notes, and snippets.

View sivartravis's full-sized avatar

Travis Taylor sivartravis

  • Cambridge, MA
View GitHub Profile
@sivartravis
sivartravis / margintale_blog_2.R
Created February 25, 2016 23:09 — forked from theHausdorffMetric/margintale_blog_2.R
Time Series Heatmaps in ggplot2
require(quantmod)
require(ggplot2)
require(reshape2)
require(plyr)
require(scales)
# Download some Data, e.g. the CBOE VIX
getSymbols("^VIX",src="yahoo")
# Make a dataframe
@sivartravis
sivartravis / us_states_hexgrid.geojson
Created February 25, 2016 22:55 — forked from hrbrmstr/us_states_hexgrid.geojson
hexbin faceted choropleths in R
library(rgdal)
library(rgeos)
library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(grid)
us <- readOGR("us_states_hexgrid.geojson", "OGRGeoJSON")
@sivartravis
sivartravis / README.md
Created February 25, 2016 21:15 — forked from timelyportfolio/README.md
d3_exploding_boxplot as R htmlwidget
#look at steps in constructing a horizon plot version
#of http://www.mebanefaber.com/timing-model/
#do horizon of percent above or below 10 month / 200 day moving average
require(lattice)
require(latticeExtra)
require(quantmod)
#since we are focused on the horizon plot, let's just look at one stock
library(magrittr)
library(dplyr)
library(nycflights13)
library(evaluate)
library(ggplot2)
# Define the plot
makeplot <- function(mydata){
date <- as.Date(paste("2013", mydata[1,"month"], mydata[1,"day"], sep="-"))
ggplot(mydata, aes(distance, arr_delay)) +
@sivartravis
sivartravis / d3.layout.timeline.js
Created February 25, 2016 21:12 — forked from emeeks/d3.layout.timeline.js
Radial Timeline
(function() {
d3.layout.timeline = function() {
var timelines = [];
var dateAccessor = function (d) {return new Date(d)};
var processedTimelines = [];
var startAccessor = function (d) {return d.start};
var endAccessor = function (d) {return d.end};
var size = [500,100];
var timelineExtent = [-Infinity, Infinity];
var setExtent = [];
@sivartravis
sivartravis / README.md
Created February 25, 2016 21:11 — forked from curran/README.md
Stacked Bars
@sivartravis
sivartravis / README.md
Created February 25, 2016 21:10 — forked from curran/README.md
Lynchings by State Donut Charts
@sivartravis
sivartravis / README.md
Created February 25, 2016 21:09 — forked from eesur/README.md
d3 | reusable slopegraph v2

Updated reusable slopegraph sketch, from my previous slopegraph version

This version allows for multiple sets/columns and will adapted accordingly. Added some interaction to toggle the sets/columns and also toggle highlighted line.

data source

@sivartravis
sivartravis / animate.R
Created February 25, 2016 21:08 — forked from thomasp85/animate.R
Animating graph over time
library(ggraph)
library(gganimate)
library(igraph)
# Data from http://konect.uni-koblenz.de/networks/sociopatterns-infectious
infect <- read.table('out.sociopatterns-infectious', skip = 2, sep = ' ', stringsAsFactors = FALSE)
infect$V3 <- NULL
names(infect) <- c('from', 'to', 'time')
infect$timebins <- as.numeric(cut(infect$time, breaks = 100))
# We want that nice fading effect so we need to add extra data for the trailing