Skip to content

Instantly share code, notes, and snippets.

View epijim's full-sized avatar

James Black epijim

View GitHub Profile
@epijim
epijim / googlelatitude_to_plot.py
Last active July 22, 2022 09:44
Take location data from google takeout, convert from json to kml and overlay on satellite photo
#I've merged code from two different sources, originally published by github users snowdonjames and Scarygami
#Import JSON, spit out KML
#usage.. location_history_json_converter.py input output [-h] [-f {kml,json,csv,js,gpx,gpxtracks}] [-v]
from __future__ import division
import sys
import json
import math
# SETUP #########################################################################
setwd("/Users/Jimmy/Dropbox/Personal/fun with code/xkcd")
library(xkcd)
library(extrafont)
library(ggplot2)
#Load scatter dataset
collegesdata <- read.csv("~/Dropbox/Personal/fun with code/xkcd/collegesdata.csv"
@epijim
epijim / TwitterFromR.r
Created January 10, 2014 12:25
access twitter API from R and make a word cloud
setwd("~/R/RStudio/twitterwordcloud")
#install the necessary packages
#install.packages("ROAuth")
#install.packages("twitteR")
#install.packages("wordcloud")
#install.packages("tm")
library("ROAuth")
library("twitteR")
@epijim
epijim / GoogleVisAndR.r
Last active January 2, 2016 22:59
GoogleVis from R
# SETUP #########################################################################
#The following packages need to be installed
require(googleVis)
setwd("~/Dropbox/Personal/fun with code/GoogleVis")
# Load data #########################################################################
@epijim
epijim / FacebookFromR.r
Last active November 20, 2023 23:29
scrape facebook from R. Based off
###############################################################################################
## ##
## Setup ##
## ##
###############################################################################################
# install.packages("Rfacebook") # from CRAN
# install.packages("Rook") # from CRAN
# install.packages("igraph") # from CRAN
@epijim
epijim / greatcircles.r
Created January 26, 2014 17:49
greatcircles
#############################################################################
####### Prelim stages ##########
#############################################################################
library(maps)
library(geosphere)
library(RCurl)
library(RJSONIO)
library(ggmap)
library(qdap)
@epijim
epijim / college_data.csv
Last active August 29, 2015 13:56
Cambridge college data
We can make this file beautiful and searchable if this error is corrected: It looks like row 6 should actually have 37 columns, instead of 16 in line 5.
College,Grad_coll,Wine_budget,Fellows,Students,Grads,PhD,Other,Rating,Part_time,Undergrad_applications ,Undergrad_acceptances ,Undergrad_acceptRate,Founded,Percent_male,Percent_female,Fixed_assets,Tompkin_1997,Tompkin_1998,Tompkin_1999,Tompkin_2000,Tompkin_2001,Tompkin_2002,Tompkin_2003,Tompkin_2004,Tompkin_2005,Tompkin_2006,Tompkin_2007,Tompkin_2008,Tompkin_2009,Tompkin_2010,Tompkin_2011,Tompkin_2012,Tompkin_2013,Tompkin_Mean09to13,TompkinsScore_2013,Firsts_2013
Christ's,FALSE,71055,84,617,208,127,81,B,Yes,451,99,22,1505,58,42,66602000,3,2,1,1,1,4,2,2,4,6,2,8,13,12,6,9,8,4.9,66.76,24.7
Churchill,FALSE,87685,165,770,290,190,100,B,Yes,350,89,25,1960,71,29,105978346,15,13,20,15,9,10,9,19,18,13,15,6,7,3,10,5,5,11.3,68.17,28.3
Clare,FALSE,79989,120,816,312,190,122,A,Yes,573,134,23,1326,52,48,70707000,11,6,15,9,6,3,6,4,9,12,17,13,18,8,4,11,11,9.6,66.08,25.3
Clare Hall,TRUE,17400,67,181,181,96,85,B,Yes,,,,1965,47,53,10579203,,,,,,,,,,,,,,,,,,,,
Corpus Christi,FALSE,79254,54,483,223,145,78,B,Yes,200,68,34,1352,60,40
@epijim
epijim / Sankey.R
Last active August 29, 2015 13:56 — forked from aaronberdanier/Sankey.R
SankeyR <- function(inputs, losses, unit, labels, format="plot"){
########################
# SankeyR version 1.01 (updated August 10, 2010)
# is a function for creating Sankey Diagrams in R.
# See http://www.sankey-diagrams.com for excellent examples of Sankey Diagrams.
#
# OPTIONS:
# 'inputs' is a vector of input values
# 'losses' is a vector of loss values
# 'unit' is a string of the unit
setwd("~/Dropbox/Personal/fun with code/sankey_arrow")
sourc.https <- function(url, ...) {
# install and load the RCurl package
if (match('RCurl', nomatch=0, installed.packages()[,1])==0) {
install.packages(c("RCurl"), dependencies = TRUE)
require(RCurl)
} else require(RCurl)
# parse and evaluate each .R script
@epijim
epijim / AtcSearch.R
Created February 11, 2014 15:40 — forked from Xachriel/AtcSearch.R
require(gdata)
require("RCurl")
require("XML")
AtcSearch <- function(AtcCodes){
#Function inside a function is bad practice...
#DummySearch searches for one atc code
DummySearch <- function(Code){
#A link to WHO search