Skip to content

Instantly share code, notes, and snippets.

View mollietaylor's full-sized avatar

Shawn Mollie Taylor mollietaylor

View GitHub Profile
gps <- read.csv("out.csv",
header = TRUE)
library(ggmap)
mapImageData <- get_googlemap(center = c(lon = median(gps$Longitude), lat = median(gps$Latitude)),
zoom = 11,
# size = c(500, 500),
maptype = c("terrain"))
ggmap(mapImageData,
@mollietaylor
mollietaylor / index.html
Created November 21, 2013 14:29
Import JSON Data from an External File in Leaflet
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>Cities I've Been To</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 / dateFormats.R
Created August 17, 2013 19:58
Date Formats in R
# importing dates:
dates <- c("05/27/84", "07/07/05")
betterDates <- as.Date(dates,
format = "%m/%d/%y") # here you put the format your dates are currently in
# it will output the ISO standard dates (%Y-%m-%d)
# or:
dates <- c("May 27 1984", "July 7 2005")
betterDates <- as.Date(dates,
@mollietaylor
mollietaylor / log.R
Created June 23, 2013 22:58
Plot Weekly or Monthly Totals in R
library(ggplot2)
library(scales)
# load data:
log <- data.frame(Date = c("2013/05/25","2013/05/28","2013/05/31","2013/06/01","2013/06/02","2013/06/05","2013/06/07"),
Quantity = c(9,1,15,4,5,17,18))
log
str(log)
# convert date variable from factor to date format:
@mollietaylor
mollietaylor / index.html
Created January 22, 2014 18:44
Add and Remove Leaflet Circle on Click
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>Click Circle</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 / subfigures.tex
Created October 31, 2012 04:08
Subfigures in LaTeX
\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\begin{document}
\begin{figure}
\centering
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mollietaylor
mollietaylor / stacked.R
Created December 11, 2012 23:55
Stacked Bar Charts in R
# cite: http://stat.ethz.ch/R-manual/R-patched/library/stats/html/reshape.html
# cite: http://www.cs.grinnell.edu/~rebelsky/Courses/MAT115/2008S/R/stacked-bar-graphs.html
# cite: http://www.harding.edu/fmccown/r/#barcharts
library(RColorBrewer)
sequential <- brewer.pal(6, "BuGn")
Loblolly[1:10,]
wide <- reshape(Loblolly,
@mollietaylor
mollietaylor / map-new-legend.R
Created September 29, 2013 23:02
Custom Legend in R
library(OIdata)
library(RColorBrewer)
library(classInt)
# load state data from OIdata package:
data(state)
# set constants:
nclr <- 8 # number of bins
min <- 0 # theoretical minimum
@mollietaylor
mollietaylor / fit.R
Last active October 21, 2018 21:52
ggplot or Lattice Fit Line in R
ols <- lm(Temp ~ Solar.R,
data = airquality)
summary(ols)
str(ols)
plot(Temp ~ Solar.R,
data = airquality)
abline(ols)