Skip to content

Instantly share code, notes, and snippets.

View epijim's full-sized avatar

James Black epijim

View GitHub Profile
@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 / 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 / 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 / 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")
# 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 / 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
@epijim
epijim / mapit.r
Created December 5, 2013 12:38
mapping the police data
theme_bare <- theme(axis.line = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
axis.title.x = element_blank(),
axis.title.y = element_blank(),
legend.position = "none")
cambridge <- get_map(location="Cambridge, UK", zoom=13, color="bw", source="osm")
@epijim
epijim / load_CamCrimeData.r
Last active December 30, 2015 08:39
load in data from data.police.uk
setwd("Directoy where the data is saved")
library(plyr) # used to read in csvs
library(psych) # has the describe function
################
# import data #
################
# Data is in monthly CSV's, so loop over them pulling in data
@epijim
epijim / mapping_cam.r
Last active December 29, 2015 17:39
Mapping Cambridge
library(ggmap)
getLineColor <- function(val) {
#pal <- colorRampPalette(c("#333333", "#ffffff", "#b5310c"))
pal <- colorRampPalette(c("#ffffff", "red"))
colors <- pal(80)
val.log <- log(val)
if (val > 50) {
col <- colors[80]
\documentclass[12pt]{article}
\usepackage{sparklines} % makes inline curves
\begin{document}
Ten-year modelled CVD risk was 27.3 (SD 13.9, histogram
\begin{sparkline}{4} % start first sparkline
\sparkspike .083 .69 % first is x spacing, second is height
\sparkspike .25 .97