Skip to content

Instantly share code, notes, and snippets.

View tacookson's full-sized avatar

Alex Cookson tacookson

View GitHub Profile
@tacookson
tacookson / clean-hbcu-enrollment
Last active February 2, 2021 21:57
clean-hbcu-enrollment
### Load packages -------------------------------------------------------------
library(tidyverse) # General-purpose cleaning
library(janitor) # For the clean_names() function
### Import data ---------------------------------------------------------------
hbcu_all <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-02-02/hbcu_all.csv') %>%
# clean_names() converts field names to snake_case
clean_names()
@tacookson
tacookson / clean-washington-trails.txt
Last active November 25, 2020 02:53
clean-washington-trails
### Load libraries
library(tidyverse)
### Load data
hike_data_raw <- read_rds(url('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-11-24/hike_data.rds'))
### Clean hike_data
hike_data <- hike_data_raw %>%
# De-duplicate Cap Sante Park
distinct(name, location, .keep_all = TRUE) %>%
@tacookson
tacookson / canadian-turbine-animation
Last active October 27, 2020 22:36
Starter animation for Canadian Wind Turbines Tidy Tuesday (2020-10-27)
### Load libraries
library(dplyr) # For data manipulation
library(readr) # For reading CSV and parsing numbers
library(ggplot2) # For graphing
library(ggthemes) # For ggplot2 theme_map()
library(gganimate) # For animation
### Import data
### https://github.com/rfordatascience/tidytuesday/blob/master/data/2020/2020-10-27/readme.md
wind_turbine <- read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-10-27/wind-turbine.csv')
@tacookson
tacookson / antarctica-map
Created July 28, 2020 01:53
Create a map of Antarctica
library(ggplot2) # For graphing
library(mapproj) # For the polar orthographic map projection
library(ggthemes) # For theme_map()
# Get geospatial data for Antarctica only
antarctica <- map_data("world", region = "Antarctica")
ggplot(antarctica, aes(long, lat, group = group)) +
geom_polygon(fill = "#506B8E") +
# This is where the magic happens