Skip to content

Instantly share code, notes, and snippets.

View jkaupp's full-sized avatar

Jake Kaupp jkaupp

View GitHub Profile
@jkaupp
jkaupp / quasirandom.R
Created February 26, 2020 01:32
dkeyes example
library(tidyverse)
library(ggbeeswarm)
data <- read_csv("https://gist.githubusercontent.com/dgkeyes/a9b47cfa9a7bd8313e5603d18cf3d444/raw/3de0e4074db23636ebd420af78e90c4009aa10c7/oregon-economic-mobility-data.csv") %>%
set_names(c("county", "percent")) %>%
mutate(percent = parse_number(percent))
mean <- mean(data$percent)
ggplot(data, aes(x = percent, y = 0)) +
# License: Apache 2.0
turbo_colormap_data <- matrix(
c(
c(0.18995, 0.07176, 0.23217),
c(0.19483, 0.08339, 0.26149),
c(0.19956, 0.09498, 0.29024),
c(0.20415, 0.10652, 0.31844),
c(0.20860, 0.11802, 0.34607),
c(0.21291, 0.12947, 0.37314),
@jkaupp
jkaupp / flexwars.Rmd
Created May 21, 2019 00:01
Old Flexdashboard live-code
---
title: "Character Statistics From A Galaxy Far, Far Away"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
---
```{r setup, include=FALSE}
library(flexdashboard)
@jkaupp
jkaupp / scraping_nfl.R
Last active February 14, 2019 15:24
Scraping tables from NFL.com
library(tidyverse)
library(lubridate)
library(glue)
library(rvest)
libray(janitor)
scrape_nfl_table <- function(url, page) {
glue("{url}&d-447263-p={page}") %>%
@jkaupp
jkaupp / merge_tbls.R
Last active April 13, 2018 00:54
Reading in multiple tables in excel file, groups delimited by #
library(tidyverse)
library(rlang)
merge_tbls <- function(x) {
col <- sym(names(x)[1])
idx <- filter(x, grepl("#", !!col)) %>%
pull(!!col) %>%
parse_number()
@jkaupp
jkaupp / stem_funding_plot.R
Last active April 27, 2018 17:53
STEM Funding Plot
library(tidyverse)
library(qualtRics)
library(rlang)
library(viridis)
library(hrbrthemes)
registerOptions(api_token="TOTALLY_NOT_MY_TOKEN", root_url="https://queensu.qualtrics.com")
surveys <- getSurveys()
@jkaupp
jkaupp / labels_on_plots
Created April 9, 2018 23:17
One method for adding nicely aligned labels to line graphs in ggplot2
library(tidyverse)
library(nycflights13)
plot_data <- flights %>%
filter(carrier %in% c("AA","UA")) %>%
count(year, month, carrier)
ggplot(plot_data, aes(x = month, y = n, group = carrier)) +
geom_path() +
geom_text(data = filter(plot_data, month == 12), aes(label = carrier), nudge_x = 0.5) +
@jkaupp
jkaupp / ceab document counts.R
Created October 12, 2017 16:25
CEAB Document stats
ceab_docs <- list.files('~/owncloud/feas/ceab/ceab reports/2016', pattern = ".pdf", full.names = TRUE, recursive = TRUE)
library(pdftools)
test <- tibble(dept = stri_extract_first_regex(ceab_docs, "CIVL|CHEE|CMPE|ENPH|ENCH|ELEC|GEOE|MECH|MTHE|MINE"), doc = basename(ceab_docs), path = ceab_docs) %>%
mutate(pages = map_dbl(path, ~pdf_info(.x)$pages)) %>%
bind_rows(., summarize(., dept = "Total",
doc = "Overall",
path = NA_character_,
pages = sum(pages))) %>%
@jkaupp
jkaupp / git-deployment.md
Created July 10, 2017 16:01 — forked from noelboss/git-deployment.md
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your lokal GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like my Deepl.io to act upon a Web-Hook that's triggered that service.

@jkaupp
jkaupp / pandoc.css
Created June 19, 2017 16:58 — forked from killercup/pandoc.css
Add this to your Pandoc HTML documents using `--css pandoc.css` to make them look more awesome. (Tested with Markdown and LaTeX.)
/*
* I add this to html files generated with pandoc.
*/
html {
font-size: 100%;
overflow-y: scroll;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}