Skip to content

Instantly share code, notes, and snippets.

View mollietaylor's full-sized avatar

Shawn Mollie Taylor mollietaylor

View GitHub Profile
@mollietaylor
mollietaylor / sectors.R
Created September 7, 2012 22:31
Map of prominent patent sectors of 50 largest U.S. cities in R
sectors <- read.table("sectors.csv", header=TRUE, sep=",")
library(maps)
library(RColorBrewer)
library(classInt)
names(sectors)
plotvar <- sectors$secnum #change this line to change data
plotclr <- brewer.pal(5,"Set1")
class <- classIntervals(plotvar, 5, 'pretty')#or pretty
colcode <- findColours(class, plotclr)
map("state", ylim=range(50, 22), col=8)
@mollietaylor
mollietaylor / histdens.R
Created September 9, 2012 17:33
Histogram + Density Plot Combo in R
png("beaverhist.png")
layout(matrix(c(1:2), 2, 1,
byrow = TRUE))
hist(beaver1$temp, # histogram
col = "peachpuff", # column color
border = "black",
prob = TRUE, # show densities instead of frequencies
xlim = c(36,38.5),
xlab = "temp",
main = "Beaver #1")
@mollietaylor
mollietaylor / reality.R
Created October 5, 2012 03:10
Random Name Generator in R
# recreating realitytvgenerator.com
# dictionary:
# define our two vectors with the names we'd like to use
first <- c("Fear", "Frontier", "Nanny", "Job", "Yard", "Airport", "Half Pint", "Commando", "Fast Food", "Basketball", "Bachelorette", "Diva", "Baggage", "College", "Octane", "Clean", "Sister", "Army", "Drama", "Backyard", "Pirate", "Shark", "Project", "Model", "Survival", "Justice", "Mom", "New York", "Jersey", "Ax", "Warrior", "Ancient", "Pawn", "Throttle", "The Great American", "Knight", "American", "Outback", "Celebrity", "Air", "Restaurant", "Bachelor", "Family", "Royal", "Surf", "Ulitmate", "Date", "Operation", "Fish Tank", "Logging", "Hollywood", "Amateur", "Craft", "Mystery", "Intervention", "Dog", "Human", "Rock", "Ice Road", "Shipping", "Modern", "Crocodile", "Farm", "Amish", "Single", "Tool", "Boot Camp", "Pioneer", "Kid", "Action", "Bounty", "Paradise", "Mega", "Love", "Style", "Teen", "Pop", "Wedding", "An American", "Treasure", "Myth", "Empire", "Motorway", "Room", "Casino", "Comedy", "Unde
@mollietaylor
mollietaylor / palettes-in-R.R
Created October 24, 2012 03:19
Palettes in R
palette()
# it's fine for your vector to include a mixture of hex triplets and R color names:
colors <- c("#A7A7A7",
"dodgerblue",
"firebrick",
"forestgreen",
"gold")
hist(discoveries,
col = colors)
@mollietaylor
mollietaylor / sort.R
Created November 13, 2012 03:56
Sorting Within Lattice Graphics in R
library(lattice)
colors = c("#1B9E77", "#D95F02", "#7570B3")
dotplot(rownames(mtcars) ~ mpg,
data = mtcars,
col = colors[1],
pch = 1)
dotplot(reorder(rownames(mtcars), cyl) ~ mpg,
data = mtcars,
@mollietaylor
mollietaylor / gini.R
Created January 2, 2013 04:08
Calculating a Gini Coefficients for a Number of Locales at Once in R
# generate random data:
city <- c("A", "B", "C", "D", "E", "F", "G", "H", "I", "J")
income <- sample(1:100000,
100,
replace = TRUE)
cities <- data.frame(city, income)
# graph our data:
library(ggplot2)
ggplot(cities,
@mollietaylor
mollietaylor / quickStart.html
Last active December 26, 2015 06:49
Make All Polygons the Same Shade in Leaflet
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>Quick Start</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
@mollietaylor
mollietaylor / presentations.txt
Created November 16, 2013 22:29
Govathon presentations
bus tracker
trash collection 404-620-5025
budget app http://public.tableausoftware.com/views/Expenses_2_0/DepartmentDashboard#1
innovations app
APS parent portal
form flow
votified http://votified.com/
geoincentives wordpress plugin
vendor application
municiplanner http://municiplanner.org/
@mollietaylor
mollietaylor / cities-coords.csv
Last active January 4, 2016 03:59
Merge by City and State in R
City State Latitude Longitude
San Francisco CA 37.7782251 -122.4424955
New York NY 40.7142691 -74.0059729
Los Angeles CA 34.0522342 -118.2436849
Chicago IL 41.850033 -87.6500523
Dallas TX 32.7830556 -96.8066667
Columbus GA 32.4609764 -84.9877094
Columbus OH 39.9611755 -82.9987942
@mollietaylor
mollietaylor / callan.R
Last active January 19, 2016 07:09
Elevation Profiles in R
gps <- read.csv("callan.csv",
header = TRUE)
# calculate moving average: (this section is optional)
library(TTR)
movingN <- 5 # define the n for the moving average calculations
gps$Altitude <- gps$Altitude * 3.281 # convert m to ft
gps$SMA <- SMA(gps$Altitude,
n = movingN)
gps <- gps[movingN:length(gps$SMA), ] # remove first n-1 points