Skip to content

Instantly share code, notes, and snippets.

View zross's full-sized avatar

Zev Ross zross

View GitHub Profile
@zross
zross / index.html
Last active August 29, 2015 14:14
Morph Montana into Idaho with D3
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: #ccc;
stroke: #000;
}
</style>
@zross
zross / ribbon
Created January 22, 2015 16:20
Create shooting ribbon plot
# quick example of creating a plot like that at the link below
# http://www.visualisingdata.com/index.php/2015/01/make-grey-best-friend/
x<-1:10
y<-x^2
z<-x
radius<-x/5
dat<-data.frame(x=x, y=y, z=z, radius=radius)
ggplot(dat, aes(x,y))+
geom_ribbon(aes(ymin=y-radius, ymax=y+radius), alpha=0.5, fill="grey", color="grey", size=1)+
@zross
zross / shakespeare.csv
Created January 14, 2015 01:39
Shakespeare word count by work (from Google BigQuery)
We can't make this file beautiful and searchable because it's too large.
"","word","word_count","corpus","corpus_date"
"1","hive",1,"loverscomplaint",1609
"2","plaintful",1,"loverscomplaint",1609
"3","Are",1,"loverscomplaint",1609
"4","Than",1,"loverscomplaint",1609
"5","attended",1,"loverscomplaint",1609
"6","That",7,"loverscomplaint",1609
"7","moisture",1,"loverscomplaint",1609
"8","praised",1,"loverscomplaint",1609
"9","particular",1,"loverscomplaint",1609
@zross
zross / colorlegend.js
Last active October 26, 2016 12:04
Animate path (with pollution values) on Leaflet map using D3
/*jshint browser:true, indent:2, globalstrict: true, laxcomma: true, laxbreak: true */
/*global d3:true */
/*
* colorlegend
*
* This script can be used to draw a color legend for a
* [d3.js scale](https://github.com/mbostock/d3/wiki/Scales)
* on a specified html div element.
* [d3.js](http://mbostock.github.com/d3/) is required.
@zross
zross / ggplot_map.R
Last active August 29, 2015 14:10
ggplot2 map using borders()
# In response to a question on our ggplot2/mapping post
# (http://zevross.com/blog/2014/07/16/mapping-in-r-using-the-ggplot2-package/)
# this is an example of using ggplot2's built-in
# borders() function and an external shapefile
# The shapefile used in that blog post is a projected shapefile
# but by default the borders() function uses unprojected
# boundaries so you will need to "unproject" the shapefile
# for the borders to match. An alternative would be to assign
# a projection with map() arguments
@zross
zross / index.html
Created November 18, 2014 19:07
Slidify blog post 0
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>R crash course</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
@zross
zross / index.html
Created November 18, 2014 18:50
Slidify blog post 3
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>R crash course</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
@zross
zross / index.html
Last active August 29, 2015 14:09
Slidify blog post 2
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>R crash course</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
@zross
zross / index.html
Created November 18, 2014 17:32
Slidify blog post 1
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>R crash course</title>
<meta name="description" content="">
<meta name="author" content="">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="stylesheet" href="http://slidifylibraries2.googlecode.com/git/inst/libraries/frameworks/revealjs/css/reveal.min.css">
@zross
zross / hooks.R
Last active November 28, 2018 02:59
Not completely finished hook to add fragment tags to RMarkdown code chunks (slidify, revealjs, R) v2
library(knitr)
opts_chunk$set(collapse=TRUE, echo=TRUE,
error=FALSE, message=FALSE,
warning=FALSE, cache=FALSE)
s0 <- knitr::knit_hooks$get('source')
o0 <- knitr::knit_hooks$get('output')
p0 <- knitr::knit_hooks$get('plot')
knitr::knit_hooks$set(