Skip to content

Instantly share code, notes, and snippets.

View alexstorer's full-sized avatar

Alex Storer alexstorer

View GitHub Profile
@alexstorer
alexstorer / intro.Rmd
Last active December 16, 2015 16:08
Introduction to R - Data Scientist Training for Librarians http://rpubs.com/alexplanation/dst4l
Introduction to R
========================================================
This file is online!
http://rpubs.com/alexplanation/dst4l
https://gist.github.com/alexstorer/5460479
@alexstorer
alexstorer / data.tsv
Last active December 16, 2015 03:49
Plots for pdurbin!
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 1 column, instead of 2 in line 1.
time seconds
1365781233.31362 0.815643072128296
1365781253.95795 0.829960107803345
1365781332.08635 0.819650888442993
1365781371.6965 0.817964792251587
1365781407.32883 1.21638607978821
# Run the topics script first to load everything up.
npi[npidtm$fd>0,c('NPI_Description','aotitle',"plocstatename","ploccityname")]
outp <- textvec[grep('FD',textvec)]
grep('FIRE',outp)
outp[grep('FIRE',outp,invert=TRUE)]
npidtm$labelhospital <- 0
hospinds <- grep("HOSPITAL",textvec)
@alexstorer
alexstorer / gist:5322931
Created April 5, 2013 21:49
Text Analysis Examples
# This is an exploration of topic modeling
# First, let's load up this pile of things.
Sys.setenv(NOAWT=TRUE)
# This is a workaround for Macs
library(tm)
library(Snowball)
@alexstorer
alexstorer / gist:5189914
Created March 18, 2013 19:10
Real Time Twittering!
import twitter
import json
import pickle
import time
import random
import sys
import csv
import twitter__login
# log in, and collect statuses containing a keyword
fname <- 'a1.txt'
ds <- read.csv(fname,col.names = c('Date','Time','File','TimeElapsed','SongTime'),header=FALSE,stringsAsFactors=FALSE)
ds$Date <- as.Date(ds$Date)
ds$Name <- fname
timelist <- strsplit(ds$Time,split=':')
for (i in 1:length(timelist)) {
hr <- timelist[[i]][[1]]
mn <- timelist[[i]][[2]]
@alexstorer
alexstorer / gist:4953783
Created February 14, 2013 16:03
Here is the RT script we worked on.
<script type="text/javascript">
shuffle = function(o){ //v1.0
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
document.onkeyup = KeyCheck;
var input = new Array();
@alexstorer
alexstorer / test.html
Created February 6, 2013 20:56
Basic demonstration of html and javascript.
<title>Alex's Webpage</title>
<head>
<style>
body
{
background-color:#b0c4de;
}
h1
{
background-color:#123456;
@alexstorer
alexstorer / parsexml.py
Created December 21, 2012 16:14
Parse some XML
from lxml import etree
import re
import csv
import os.path as op
import sys
import glob
class NLRPParse(object):
def __init__(self,fname):
@alexstorer
alexstorer / sample.R
Created December 17, 2012 21:49
Code to handle the Word documents (saved as HTML) and convert to CSV. Then, we do topic modeling with R.
setwd('~/Work/dlopez')
r <- read.csv('Sampl.csv',stringsAsFactors=FALSE)
# First, let's load up this pile of things.
Sys.setenv(NOAWT=TRUE)
# This is a workaround for Macs
library(tm)