This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a conceptual study to leverage the tidyverse syntax and lazy | |
# evaluation concepts (influenced by sparklyr) to approach API wrapper packages. | |
# | |
# Problem statement: API wrappers often require users to download *all* data | |
# to manipulate and filter the information. Some packages support custom | |
# queries but often complicate syntax by adding many parameters within the | |
# function that may be hard for data scientists to formulate. | |
# | |
# Potential solution: API queries can be separated into three principal parts. | |
# First, to query the API metadata to understand column names and data types. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"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(\" -\",\"\")", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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)) |
NewerOlder