Skip to content

Instantly share code, notes, and snippets.

View burch-cm's full-sized avatar

Christopher "Kitt" Burch burch-cm

  • Washington, DC
View GitHub Profile
@burch-cm
burch-cm / extract_weights.R
Created December 8, 2020 19:27
Extracting Vehicle Weights (or any numbers, really) from Text Descriptions
# Vehicles from the GSA have a gross vehicle weight rating (GVWR), but this is stored in the vehicle description in inconsistent
# text formats (sometimes spaces as separators, sometimes commas, sometimes no separators). One consistent thing is that the weights
# always end with 'LBS', which means it's easy enough to write a regex that can extract them from the text.
# Same GSA vehicle description
sample_text <- c("4x4 SUV 10,000 LBS GVWR", "2x4 PICKUP 7 001 LBS GVWR", "SEDAN 6000LBS")
# using {stringr} and regex:
library(stringr)
library(magrittr)
@burch-cm
burch-cm / conferamuccis.R
Last active June 16, 2020 20:14
How long did the Confederacy last in Scaramuccis?
library(lubridate)
# One Scaramucci is apx 10 days
mooch <- days(10)
# Date of the Confederate Provisional Constitution
conf_start <- ymd("1861/02/08")
# Date of surrender
conf_end <- ymd("1865/04/09")