Skip to content

Instantly share code, notes, and snippets.

View rabutler's full-sized avatar

Alan Butler rabutler

View GitHub Profile
@rabutler
rabutler / getBoxPlotLegend.R
Created May 5, 2017 21:14
Returns a generic boxplot legend, using the stat-boxplot-custom code
library(devtools)
library(ggplot2)
source_gist("38e70de658b48e166f90", filename = "theme-blank.R")
source_gist("bd97a6f49db87860f987156842fd4ee5", filename = "stat-boxplot-custom.R")
getBoxplotLegend <- function(qs = c(.05, .25, .5, .75, .95)) {
df <- data.frame(x = "a", y = c(-3:1,5:95,99:103))
@rabutler
rabutler / stat-boxplot-custom.R
Last active April 7, 2023 14:50
Use custom percentiles for whiskers in `stat_boxplot`
# modified from https://github.com/tidyverse/ggplot2/blob/master/R/stat-boxplot.r
# now takes qs argument instead of coef to extend the whiskers to a specific
# percentile
library(ggplot2)
stat_boxplot_custom <- function(mapping = NULL, data = NULL,
geom = "boxplot", position = "dodge",
...,
qs = c(.05, .25, 0.5, 0.75, 0.95),
library(rgdal)
library(sp)
library(albersusa) # devtools::install_github("hrbrmstr/albersusa")
library(spdplyr) # devtools::install_github("mdsumner/spdplyr")
library(ggplot2) # devtools::install_github("hadley/ggplot2")
library(ggthemes)
library(rgeos)
library(purrr)
library(broom)
library(magick)