Skip to content

Instantly share code, notes, and snippets.

Tom Schenk Jr tomschenkjr

Block or report user

Report or block tomschenkjr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tomschenkjr
tomschenkjr / export-socrata.R
Last active May 5, 2017
An alpha of a export.socrata() function for the RSocrata package. See https://github.com/Chicago/RSocrata/issues/126
View export-socrata.R
library(devtools)
install_github("Chicago/RSocrata" ref = "issue124") # RSocrata 1.7.2-7 or above
library(RSocrata)
#' Exports CSVs from Socrata data portals
#'
#' Input the URL of a data portal (e.g., "data.cityofchicago.org") and
#' will download all CSV files (no other files supported) and saved in
#' a single directory named after the root URL (e.g., "data.cityofchicago.org/").
#' Downloaded files are compressed to GZip format and timestamped so the download
View BASE64SHA1.vbs
Public Function BASE64SHA1(ByVal sTextToHash As String)
Dim asc As Object
Dim enc As Object
Dim TextToHash() As Byte
Dim SharedSecretKey() As Byte
Dim bytes() As Byte
Const cutoff As Integer = 5
Set asc = CreateObject("System.Text.UTF8Encoding")
@tomschenkjr
tomschenkjr / geocode.R
Created Jan 10, 2016
A note on how to geocode using R, since I always forget
View geocode.R
# A note on how to geocode using R, since I always forget
library(tigris) # also loads 'sp'
library(RSocrata)
# Obtain data
d <- read.socrata("https://data.cityofchicago.org/Education/Connect-Chicago-Locations/bmus-hp7e")
ccgeo <- tracts(state = '17', county = c('031'), cb = T) ## cb=T means smaller file
# Data organization
@tomschenkjr
tomschenkjr / Julia Workshop notes 20141115.jl
Created Nov 18, 2014
Notes from Julia Workshop: From Installed to Productive
View Julia Workshop notes 20141115.jl
# Notes from Julia Workshop: From Installed to Productive
# 2014-11-15
# http://www.meetup.com/JuliaChicago/events/216950712/
println("hello world") # => hello world
x = 5
## IF statements
@tomschenkjr
tomschenkjr / CPS_HS_Progress_Report_2014_Transformations.txt
Created Dec 18, 2013
This gist contains the original pre-converted data file for CPS High School Progress Report 2013-2014. The second file is a JSON layout that contains the transformations applied within OpenRefine to transform the data file. The file transforms the original file to the published copy at https://data.cityofchicago.org/id/2m8w-izji. These files acc…
View CPS_HS_Progress_Report_2014_Transformations.txt
[
{
"op": "core/text-transform",
"description": "Text transform on cells in column Phone Number using expression grel:value.replace(\" -\",\"\")",
"engineConfig": {
"facets": [],
"mode": "row-based"
},
"columnName": "Phone Number",
"expression": "grel:value.replace(\" -\",\"\")",
@tomschenkjr
tomschenkjr / chicago-cla-v1
Last active Dec 18, 2015
Draft of Chicago's Contributor Licensing Agreement
View chicago-cla-v1
City of Chicago
Individual Contributor License Agreement ("Agreement")
======================================================
Thank you for your interest in [Project Name] by the City of Chicago (the "City"),
a municipal corporation and home rule unit of local government existing under the
Constitution of the State of Illinois. In order to clarify the intellectual property
license granted with Contributions from any person or entity, the City must have a
Contributor License Agreement ("CLA") on file that has been signed by each Contributor,
indicating agreement to the license terms below. This license is for your protection
View CoefficientPlot.R
CoefficientPlot <- function(models, alpha = 0.05, modelnames = ""){
# models must be a list()
Multiplier <- qnorm(1 - alpha / 2)
CoefficientTables <- lapply(models, function(x){summary(x)$coef})
TableRows <- unlist(lapply(CoefficientTables, nrow))
if(modelnames[1] == ""){
ModelNameLabels <- rep(paste("Model", 1:length(TableRows)), TableRows)
} else {
@tomschenkjr
tomschenkjr / reshape-tutorial.R
Created Nov 19, 2012
Chicago Data Visualization reshape Tutorial Script
View reshape-tutorial.R
# Install reshape package. You will be asked to pick a server.
install.packages("reshape")
# We're going to also use ggplot2, so let's install that as well:
install.packages(c("reshape","ggplot2")) # In R, c() concatenates inputs as a vector
# You will always need to load the libraries after installing the package.
library(reshape)
library(ggplot2)
@tomschenkjr
tomschenkjr / ggplot2-tutorial-3.R
Created Nov 12, 2012
Chicago Data visualization ggplot2 Tutorial 3 Script
View ggplot2-tutorial-3.R
# Let's customize our plot outputs. First, load the library.
library(ggplot2)
# Plot something simple
p <- ggplot(mtcars, aes(x=cyl, y=mpg)) + geom_point(aes(color=qsec, size=wt))
# Change axis
p + scale_y_continuous(limits=c(0,40))
@tomschenkjr
tomschenkjr / ggplot2-tutorial-hw-maps.R
Created Nov 7, 2012
ggplot2 Workshop Homework for Maps
View ggplot2-tutorial-hw-maps.R
# TITLE: ggplot2 Workshop Homework for Maps
# AUTHOR: Tom Schenk Jr.
# DATE CREATED: November 7, 2012
# DATE MODIFIED: None
# PURPOSE: Create maps using R and ggplot2 library.
# LIBRARIES: ggplot2, maptools
library(ggplot2)
library(maptools)
You can’t perform that action at this time.