Skip to content

Instantly share code, notes, and snippets.

View tiernanmartin's full-sized avatar

Tiernan Martin tiernanmartin

View GitHub Profile
@tiernanmartin
tiernanmartin / style.css
Created September 22, 2018 17:17
Bookdown EPUB CSS
p {
line-height: 1.7;
}
p.caption {
color: #777;
margin-top: 10px;
}
code {
font-size: 60%
}
@tiernanmartin
tiernanmartin / utils.R
Created July 21, 2018 23:48
A template for R/utils.R in a package
#' @title A set of generic helpful functions
#' @description General purpose functions to make working in R easier.
#' @name utils
#' @import purrr
NULL
#' @rdname utils
#' @export
not_sfc <- function(x) !any(class(x) %in% 'sfc')
@tiernanmartin
tiernanmartin / interp-median.R
Created July 21, 2018 22:37
Interpolate Median Values
require(magrittr)
require(dplyr)
require(tigris)
require(acs)
require(stringr)
require(tidyr)
require(acs)
interpMedian <- function(state, county, tracts, endyear = 2014, span = 5,
tableNumber = "B19001", round = TRUE){
@tiernanmartin
tiernanmartin / world-cup-2018-coach-pool.R
Last active July 12, 2018 16:23
Update World Cup Coach Pool
# SETUP -------------------------------------------------------------------
library(janitor)
library(fuzzyjoin)
library(operator.tools)
library(rvest)
library(glue)
library(googlesheets)
library(googledrive)
library(magrittr)
@tiernanmartin
tiernanmartin / wc-2018-draft.R
Last active June 29, 2018 15:21
World Cup 2018 Draft
# SETUP -------------------------------------------------------------------
library(janitor)
library(fuzzyjoin)
library(operator.tools)
library(rvest)
library(glue)
library(googlesheets)
library(googledrive)
@tiernanmartin
tiernanmartin / distressed-county-public-libraries
Last active May 31, 2018 15:39
Map public libraries in "distressed" counties (WA)
# SETUP ----
library(mapview)
library(tigris)
library(rvest)
library(sf)
library(tidyverse)
options(tigris_class = "sf")
@tiernanmartin
tiernanmartin / 2018-05-28-roadblocks-re-framed-gist.R
Created May 29, 2018 01:41
Targeting Unicode Characters with Regular Expressions
# SETUP ----
library(tidyverse)
# LOAD DATA ----
csv_url <- "https://data.kingcounty.gov/resource/es38-6nrz.csv"
agencies <- read_csv(csv_url)
# Setup ----
library(lubridate)
library(tidyverse)
# Create a ggplot theme
theme_min_timeline <- function(){
theme_minimal() %+replace%
theme(
axis.ticks.x = element_line(size = .5),
@tiernanmartin
tiernanmartin / us-wars-comparison-gist.R
Created May 7, 2018 17:53
Comparison of US war from two sources
# Setup ----
library(Ecdat)
library(janitor)
library(ggrepel)
library(rvest)
library(scales)
library(patchwork)
library(tidyverse)
@tiernanmartin
tiernanmartin / 2018-04-23-county-count-gist.R
Last active May 8, 2018 05:57
Code for creating a plot of North Carolina's counties
# Setup ----
library(extrafont)
library(grDevices)
library(ggrepel)
library(patchwork)
library(placement)
library(rvest)
library(janitor)
library(sf)