Skip to content

Instantly share code, notes, and snippets.

View abresler's full-sized avatar

Alex Bresler abresler

View GitHub Profile

geojsonio has two ways to validate geojson (specifically geojson, not json structure itself). Via a web API from geojsonlint, or locally using the Mapbox's javascript geojsonhint library (included in the package).

Both can act directly on many different inputs, including character strings, lists, data.frame's, all the sp class spatial objects.

Install and load

@hrbrmstr
hrbrmstr / sgmarkerex.R
Created March 13, 2015 01:36
state unemployment example for blog post
library(dplyr)
library(streamgraph)
library(pbapply)
# Grab some employment data from BLS --------------------------------------
url <- "http://www.bls.gov/lau/ststdsadata.txt"
dat <- readLines(url)
# Small function to grab data for a particular state ----------------------
@timelyportfolio
timelyportfolio / shinyApp.R
Last active August 29, 2015 14:17
forked from @rich-iannone dogs example
# Obtain 'dogs.csv'
# Created by Alex Bresler, available at:
# https://github.com/abresler/abresler.github.io/blob/master/blog/2015/february/exploring_agility_show/data/dogs.csv
dat_url <- "http://asbcllc.com/blog/2015/february/exploring_agility_show/data/dogs.csv"
dogs <- read.csv(dat_url, header = TRUE, stringsAsFactors = FALSE)
library(shiny)
# Install the latest DiagrammeR package from GitHub
# devtools::install_github("rich-iannone/DiagrammeR")
library(rvest)
library(magrittr)
library(ggplot2)
library(dplyr)
library(tidyr)
library(scales)
# get page
pg <- html("http://www.bls.gov/opub/ted/2015/consumer-spending-by-age-group-in-2013.htm#tab-2")
@timelyportfolio
timelyportfolio / Readme.md
Last active August 29, 2015 14:17
TraMineR + rcdimple | Analyze State Sequence Data with dimple htmlwidget

As I read the TraMineR vignette, I thought this state sequence diagram would be an interesting use case for rcdimple. I'll throw in a little ggplot2, dplyr, tidyr, and pipeR for free.

See the live example.

@jalapic
jalapic / majorwinners
Created April 9, 2015 13:16
golf major winners
### Cumulative Golf Major Winners
library(XML)
masters <- readHTMLTable("http://en.wikipedia.org/wiki/Masters_Tournament")
masters <- masters[[4]][,1:2]
usopen <- readHTMLTable("http://en.wikipedia.org/wiki/U.S._Open_(golf)")
usopen <- usopen[[2]][,1:2]
(function(){
var margin = {
top: 20,
right: 40,
bottom: 50,
left: 40
},
width = 660 - margin.left - margin.right,
height = 340 - margin.top - margin.bottom;
@noamross
noamross / base_r_plotting_tutorial_koontz_d-rug.r
Created April 24, 2015 17:34
Back to basics: High quality plots using base R graphics
### Title: Back to basics: High quality plots using base R graphics
### An interactive tutorial for the Davis R Users Group meeting on April 24, 2015
###
### Date created: 20150418
### Last updated: 20150423
###
### Author: Michael Koontz
### Email: [email protected]
### Twitter: @michaeljkoontz
###
@jebyrnes
jebyrnes / leafletMapWithLegend.R
Last active August 29, 2015 14:19
A demo of leaflet using a color legend
#devtools::install_github("rstudio/leaflet", ref="feature/color-legend")
library(leaflet)
library(RColorBrewer)
set.seed(100)
pdf <- data.frame(Latitude = runif(100, -90,90), Longitude = runif(100, -180,180))
#make a property with colors
pdf$Study <- rep(1:10,10)
#need to create a pal using colorbin
@hrbrmstr
hrbrmstr / us_states_hexgrid.geojson
Last active April 9, 2021 06:10
hexbin faceted choropleths in R
library(rgdal)
library(rgeos)
library(ggplot2)
library(readr)
library(tidyr)
library(dplyr)
library(grid)
us <- readOGR("us_states_hexgrid.geojson", "OGRGeoJSON")