Skip to content

Instantly share code, notes, and snippets.

View reubano's full-sized avatar

Reuben Cummings reubano

View GitHub Profile
mid_range <- function(x) mean(range(x, na.rm = TRUE))
centres <- ddply(county_df, c("state", "county"), summarise,
lat = mid_range(lat),
long = mid_range(long)
)
bubbles <- merge(centres, unemp, by = c("state", "county"))
ggplot(bubbles, aes(long, lat)) +
geom_polygon(aes(group = group), data = state_df,
colour = "white", fill = NA) +
plot.heat <- function(tmp,state.map,z,title=NULL,breaks=NULL,cex.legend=1,bw=.2,col.vec=NULL,main=NULL,plot.legend=TRUE, ...) {
tmp@data$zCat <- cut(tmp@data[,z],breaks,include.lowest=TRUE)
cutpoints <- levels(tmp@data$zCat)
if (is.null(col.vec)) col.vec <- heat.colors(length(levels(tmp@data$zCat)))
cutpointsColors <- col.vec
levels(tmp@data$zCat) <- cutpointsColors
cols <- as.character(tmp$zCat)
##cols <- "white"
plot(tmp,border=cols, lwd=bw,axes = FALSE, las = 1,col=as.character(tmp@data$zCat),main="A", ...)
if (!is.null(state.map)) {
@dsibilly
dsibilly / related_models.py
Created May 11, 2011 20:31
SQLAlchemy related models demo
@osteslag
osteslag / version.sh
Created July 18, 2011 12:45
Script for managing build and version numbers using git and agvtool. See link in comments below.
#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
# v1.1 29-Sep-12 Launch git, agvtool via xcrun.
version() {
@kennym
kennym / blogspot_to_jekyll.rb
Created July 30, 2011 18:14
Migrate your blogger blog posts to jekyll.
#!/usr/bin/env ruby
#
# Convert blogger (blogspot) posts to jekyll posts
#
# Basic Usage
# -----------
#
# ./blogger_to_jekyll.rb feed_url
#
# where `feed_url` can have the following format:
@dsanson
dsanson / any2pandoc.sh
Created August 30, 2011 17:52
any2pandoc.sh: script that tries to convert documents thrown at it to pandoc's extended markdown
#!/bin/sh
# any2pandoc.sh
#
# A shell script that tries its best to convert documents thrown at it
# to pandoc's extended markdown.
#
# https://gist.github.com/1181510
#
# Depends on:
@acdha
acdha / postmkvirtualenv
Created September 2, 2011 13:07
My virtualenvwrapper postmkvirtualenv hook
#!/bin/bash
# This hook is run after a new virtualenv is activated.
set -e
(cat <<'PYDOC'
#!/usr/bin/env python
import pydoc
if __name__ == '__main__':
pydoc.cli()
@bergie
bergie / .gitignore
Created September 19, 2011 15:50
Node.js email handling examples
config.json
reading-image.png
@battlehorse
battlehorse / multi_dashboard.html
Created September 26, 2011 14:28
A Google Charts dashboard setup where multiple datatables are used to power a single 'logical' dashboard.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['controls']});
@reubano
reubano / formatstrings.R
Created October 12, 2011 11:48
Choropleths in R
#load data
stateAbbr rownames(stateAbbr)unemp_data
#get county names in correct format
countyNames counties statesstates
#concatenate states and counties
unemp_data$counties
#parse out county titles & specifics