Skip to content

Instantly share code, notes, and snippets.

View pschmied's full-sized avatar

Peter Schmiedeskamp pschmied

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pschmied
pschmied / super-literate.org
Last active September 22, 2017 23:09
Emacs / Org-mode demo

In the beginning, there was text… and it was good.

We didn’t have need for high falutin rich text hypermedia science fiction mumbo jumbo. At its core, org-mode is just exactly this: text. Org-mode may be daunting, but when you feel overwhelmed, breathe and know that org-mode’s lowest common denominator is just plain text.

Sometimes, however, text alone doesn’t adequately convey intent. Occasionally we need to be bold or otherwise add emphasis

@pschmied
pschmied / snap-year-change.r
Last active July 29, 2017 15:51
Plotting month-over-month change in snap users
library(tidyverse) # Start with the tidyverse, yo!
library(lubridate) # Hey mate, use lubridate!
df <- tibble( # Like data.frame, but tidyverse...ier
month = month(1:12, label = 12),
cases = c(
2291999, 2295025, 2305049, 2298570,
2312778, 2322623, 2323876, 2335145,
2324974, 2327760, 2363594, 2394956)
) %>% # Pipes are part of tidyverse / common in modern R
@pschmied
pschmied / salary-explore.r
Last active July 10, 2017 15:41
Playing with predicting gender / race from names
library(tidyverse)
library(readr)
library(stringr)
library(scales)
library(wru) # Predict race
library(gender) # Predict gender
## Employees / salary info for Chicago
df_sal <- read_csv("https://data.cityofchicago.org/api/views/xzkq-xp2w/rows.csv?accessType=DOWNLOAD")
@pschmied
pschmied / *scratch*.el
Created June 29, 2017 23:36
Vega-lite example
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"data": {"url": "https://data.seattle.gov/api/views/mags-97de/rows.csv"},
"selection": {
"grid": {
"type": "interval", "bind": "scales"
}
},
"mark": "circle",
"encoding": {
@pschmied
pschmied / dsmpapi.org
Last active June 21, 2017 20:48
Using DSMP API from R

Publishing a dataset using DSMP API from R

These are some notes I made to reason through / illustrate usage of the new DSMP API. Usage here is presented as a linear set of steps for pedagogical purposes rather than attempting to create a reusable set of functions or a library.

Creating a new R client library based around the DSMP API is a task for the hopefully-not-too-distant future.

@pschmied
pschmied / knitr-example.Rnw
Last active March 31, 2017 00:53
An example of an xtable and some graphics in knitr w/LaTeX
% I use the memoir class for everything. `texdoc memoir` from your command
% prompt (on Mac & Linux anyway) has all the details. It's better.
\documentclass[11pt,letterpaper,article]{memoir} % for a short document
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{latexsym}
% Useful for Knitr. Otherwise, I use memoir class's 'ctabular' env.
\usepackage{longtable}
\newsubfloat{figure}% Allow subfloats in figure environment
@pschmied
pschmied / voting-power.png
Last active November 20, 2016 09:25
Relative voting power by state
voting-power.png
@pschmied
pschmied / poisson-gamma-postpred.ipynb
Last active July 4, 2016 13:57
Sampling from a posterior predictive distribution in IJulia. See http://nbviewer.ipython.org/gist/pschmied/b443e5e2d876b5ce9627 for rendered version.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pschmied
pschmied / obesity-by-state.R
Created November 5, 2013 19:51
Plot of state obesity rates in descending order
# Statewide obesity data
# from http://massey.limfinity.com/data/
library(gdata)
library(ggplot2)
# stringsAsFactors=FALSE is important more often than not.
obesity <- read.xls("http://massey.limfinity.com/data/obesity.xls",
sheet=1, stringsAsFactors=FALSE)