Skip to content

Instantly share code, notes, and snippets.

View svmiller's full-sized avatar
🤷‍♂️
¯\_(ツ)_/¯

Steven V. Miller svmiller

🤷‍♂️
¯\_(ツ)_/¯
View GitHub Profile
@svmiller
svmiller / clemson-weather-data.csv
Created October 28, 2018 14:38
Clemson Weather Data (1950-1980, 2017)
We can't make this file beautiful and searchable because it's too large.
date,datatype,station,value,fl_m,fl_q,fl_so,fl_t
1950-01-01T00:00:00,TMAX,GHCND:USC00381770,117,,,0,0800
1950-01-02T00:00:00,TMAX,GHCND:USC00381770,183,,,0,0800
1950-01-03T00:00:00,TMAX,GHCND:USC00381770,194,,,0,0800
1950-01-04T00:00:00,TMAX,GHCND:USC00381770,189,,,0,0800
1950-01-05T00:00:00,TMAX,GHCND:USC00381770,217,,,0,0800
1950-01-06T00:00:00,TMAX,GHCND:USC00381770,217,,,0,0800
1950-01-07T00:00:00,TMAX,GHCND:USC00381770,183,,,0,0800
1950-01-08T00:00:00,TMAX,GHCND:USC00381770,128,,,0,0800
1950-01-09T00:00:00,TMAX,GHCND:USC00381770,133,,,0,0800
@svmiller
svmiller / american-conflict-support-casualties.csv
Created July 11, 2018 01:32
Data, cobbled from Larson (1996) and Gallup/iCasualties (AFG, IRQ) for American support for conflict, by running casualty count
War Date Casualties Support
WWII 1941-12-07 2400 86
WWII 1942-02-01 16247 87
WWII 1943-02-01 17899 92
WWII 1943-09-04 24127 89
WWII 1944-02-02 30736 77
WWII 1946-04-10 217000 77
WWII 1943-03-01 20737 85.5
WWII 1944-05-07 36274 81
WWII 1944-08-30 67806 82
@svmiller
svmiller / scrape-tidy-presidency-project-approval-data.R
Created May 22, 2018 15:10
Scrape American Presidency Project Approval Data
library(rvest)
library(lubridate)
library(tidyverse)
Truman <- read_html("http://www.presidency.ucsb.edu/data/popularity.php?pres=33")
Truman %>%
html_table(fill=T) -> Truman
Truman[[11]] -> Truman
library(tidyverse)
library(stevemisc)
# Load data
Non <- read_csv("~/Dropbox/data/cow/wars/Non-StateWarData_v4.0.csv")
Intra <- read_csv("~/Dropbox/data/cow/wars/Intra-StateWarData_v4.1.csv")
Inter <- read_csv("~/Dropbox/data/cow/wars/Inter-StateWarData_v4.0.csv")
Extra <- read_csv("~/Dropbox/data/cow/wars/Extra-StateWarData_v4.0.csv")
@svmiller
svmiller / twitter-art.md
Last active November 15, 2018 00:48
Useful for my purposes when I want to make a funny (lol, I know...) on the Twitter-dot-coms.

| ̄ ̄ ̄ ̄ ̄  ̄| | DEATH | | IS | | INEVITABLE | | _______| (__/) || (•ㅅ•) || /   づ

(・_・)っ

@svmiller
svmiller / 1-gawk-at-fariss-lhr-data.R
Created November 15, 2017 23:04
Poking around Fariss' (2014) LHR data.
library(tidyverse)
library(lubridate) # just in case I need to manipulate a date
library(stringr) # just in case I need to manipulated a string
library(stevemisc) # for my personal theme
library(scales) # just in case I need to fudge a y-axis to be a scale
library(knitr) # just in case I need a markdown table
# I'm going to assume you have Fariss' data downloaded somewhere. Here's what mine looks like.
LHR <- read_csv("~/Dropbox/data/latent-human-rights/HumanRightsProtectionScores_v2.04.csv")
@svmiller
svmiller / 1-scrape-noaa.R
Created June 20, 2017 15:24
Get Phoenix airport June highs data
library(rnoaa)
library(tidyverse)
library(stringr)
library(weathermetrics)
my_token <- "get your own here..."
theme_steve <- function() {
theme_bw() +
theme(panel.border = element_blank(),
@svmiller
svmiller / terrorism-in-ukg-1970-2015.R
Created June 4, 2017 20:15
Model terrorism patterns in the United Kingdom
# You won't need all of these packages. I just copied it from another,related analysis:
# https://github.com/svmiller/etjc
library(car)
library(arm)
library(countrycode)
library(data.table)
library(tidyverse)
library(sqldf)
# library(pdftools)
library(RCurl)
library(tidyverse)
library(maps)
# library(fiftystater)
theme_steve <- function() {
theme_bw() +
theme(panel.border = element_blank(),
plot.caption=element_text(hjust=1, size=9,
margin=margin(t=10),
setwd("~/Dropbox/projects/blog-posts/nato-spending")
library(WDI)
library(countrycode)
library(tidyverse)
Milit <- WDI(country="all", indicator=c("MS.MIL.XPND.GD.ZS", "MS.MIL.XPND.ZS","MS.MIL.TOTL.P1", "SP.POP.TOTL"),
start=1988, end=2015) %>%
rename(milex = MS.MIL.XPND.GD.ZS, milgovexp = MS.MIL.XPND.ZS,
milper = MS.MIL.TOTL.P1, tpop = SP.POP.TOTL) %>% tbl_df() %>%