Skip to content

Instantly share code, notes, and snippets.

View blmoore's full-sized avatar
🙆‍♂️

Benjamin L. Moore blmoore

🙆‍♂️
View GitHub Profile
@blmoore
blmoore / USemploymentPlot.R
Last active August 29, 2015 13:56
for blogpost
require("zoo")
require("ggplot2")
# unemployment
u <- read.csv("Employment.csv", header=T)
u <- melt(u, "Year")
unemployment <- data.frame(date=as.yearmon(do.call(paste, u[,1:2]), "%Y %b"),
rate=u$value)
unemployment <- unemployment[unemployment$date > as.yearmon("2008-12"),]
@blmoore
blmoore / PRNGanalysis.R
Last active August 29, 2015 13:57
For blog post
library("jsonlite")
library("stringr")
oauth <- scan("yourOAuth.token", "character")
getCMD <- function(user){
# crude system command for querying Github API
newcmd <- paste0("curl -H 'Accept: application/vnd.github.v3.text-match+json Authorization: token ",
oauth, "' 'https://api.github.com/search/code?q=set.seed+in:file+language:R+user:",
user,"&page=1&per_page=500' | grep 'fragment' -")
library("ggplot2")
library("scales")
## Data: http://www.theguardian.com/news/datablog/2009/oct/21/icm-poll-data-labour-conservatives#data (State of the parties spreadsheet)
# ICM poll resultsof ~1000 people taken every month or so
# (more often before an election) as well as election
# results dating from June 1984.
sop <- read.csv("StateOfTheParties.csv", stringsAsFactors=F)
## Data cleanup
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://dimplejs.org/dist/dimple.v1.1.1.min.js' type='text/javascript'></script>
<style>
.rChart {
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='http://nvd3.org/assets/css/nv.d3.css'>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://timelyportfolio.github.io/rCharts_nvd3_tests/libraries/widgets/nvd3/js/nv.d3.min-new.js' type='text/javascript'></script>
<script src='http://nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script>
@blmoore
blmoore / index.html
Last active August 29, 2015 14:02
testing js plot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://dimplejs.org/dist/dimple.v1.1.1.min.js' type='text/javascript'></script>
<style>
.rChart {
@blmoore
blmoore / index.html
Last active August 29, 2015 14:06
The top 50 science stars of Twitter
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://dimplejs.org/dist/dimple.v1.1.1.min.js' type='text/javascript'></script>
<style>
.rChart {
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//dimplejs.org/dist/dimple.v2.1.0.min.js' type='text/javascript'></script>
<style>
.rChart {
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//dimplejs.org/dist/dimple.v2.1.0.min.js' type='text/javascript'></script>
<style>
.rChart {
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//dimplejs.org/dist/dimple.v2.1.0.min.js' type='text/javascript'></script>
<style>
.rChart {