Skip to content

Instantly share code, notes, and snippets.

## Start with the code and data here: https://github.com/fivethirtyeight/data/blob/master/police-deaths/plot.R
## Then:
## Calculate total deaths by year
dat <- data_for_plot %>%
group_by(year) %>%
mutate(total = sum(count))
## Colors I chose
mycolors <- c("#00bf7b", "#59004d", "#ffcb89", "#a76e61", "#ac270d", "#7890ff",
@karawoo
karawoo / ampad_accession.R
Created July 3, 2019 16:34
Follower accession counts for @AMPADPortal
## Follower accession chart for AMPADportal
## Inspired by: https://blog.ouseful.info/2013/04/05/estimated-follower-accession-charts-for-twitter/
library("rtweet")
library("tidyverse")
followers <- get_followers("AMPADPortal")
followers_df <- lookup_users(followers$user_id)
process_user_data <- function(data) {
library("cholera")
library("tidyverse")
library("magick")
library("grid")
library("egg")
# Get image
bree <- image_read("https://pbs.twimg.com/media/EBPHuylUIAAziJt?format=jpg")
# Add x/y coordinates of Broad St. pump and convert format
@karawoo
karawoo / count-code-reviews.R
Created October 28, 2019 20:48
Count number of code reviews on a repo
############################################
#### Calculate number of code reviews ####
############################################
## Needs a GitHub PAT or you'll hit rate limiting
library("gh")
library("purrr")
library("glue")
@karawoo
karawoo / reprex.R
Created April 24, 2020 21:32
reprex demo
#######################
#### Reprex demo ####
#######################
## 2020-04-24
# A simple reprex --------------------------------------------------------------
dat <- data.frame(a = 1:2, b = LETTERS[1:2])
mean(dat$a)