Skip to content

Instantly share code, notes, and snippets.

💭
Hungry

Matt Sandy MattSandy

💭
Hungry
View GitHub Profile
@MattSandy
MattSandy / census.R
Last active Apr 8, 2020
NYT Covid-19 Data Merged with Census
View census.R
library(tidycensus)
library(tidyverse)
library(viridisLite)
library(gganimate)
library(patchwork)
us_county_population <- get_estimates(geography = "county",
product = "population",
shift_geo = TRUE, geometry = TRUE,
year = 2018) %>%
@MattSandy
MattSandy / South_Korea_COVID-19.R
Created Mar 17, 2020
Plot confirmed COVID-19 cases in SK
View South_Korea_COVID-19.R
library(tidyverse)
library(lubridate)
library(ggthemes)
library(forecast)
library(xts)
library(timetk)
future <- 7
confirmed <- read_csv("https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv")
South_Korea <- list()
@MattSandy
MattSandy / usa.R
Created Mar 12, 2020
Plots a 7 day forecast for the Coronavirus
View usa.R
library(tidyverse)
library(lubridate)
library(ggthemes)
library(forecast)
library(xts)
library(timetk)
future <- 7
confirmed <- read_csv("https://github.com/CSSEGISandData/COVID-19/raw/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv")
@MattSandy
MattSandy / crime.R
Created Nov 13, 2019
Compares Party with Violent Crime Stats in Top 50 US Cities
View crime.R
library(tidyverse)
library(rvest)
library(magrittr)
# Functions ---------------------------------------------------------------
dfmd <- function(df) {
md <- paste(names(df), collapse = " | ")
md %<>% append(rep("---",length(names(df))) %>% paste(collapse = "|"))
for(i in 1:nrow(df)) {
@MattSandy
MattSandy / run.R
Created Sep 13, 2019
Third Democratic Debate
View run.R
library(tidyverse)
library(rvest)
library(data.table)
library(quanteda)
library(magrittr)
library(ggthemes)
url <- "https://www.washingtonpost.com/" %>%
paste0("politics/2019/09/13/transcript-third-democratic-debate/")
transcript <- url %>% read_html %>%
@MattSandy
MattSandy / front_page.R
Created Sep 3, 2019
Gets the subreddits that made it to the front page the most often
View front_page.R
library(tidyverse)
library(jsonlite)
library(plotly)
# Figure out which columns are lists
drop_lists <- function(df) {
for(column in names(df)) {
if(typeof(df[[column]])=="list") {
# Remove column
df[[column]] <- NULL
@MattSandy
MattSandy / run.js
Last active Aug 14, 2019
Get character length of every document on the page
View run.js
var all = document.getElementsByTagName("*");
var tags = [];
var tmp = 0;
for (var i=0, max=all.length; i < max; i++) {
tmp = 0;
jQuery.each(all[i].attributes,function(pos,element){
tmp = tmp + element.name.length + element.value.length;
});
tmp = tmp + jQuery(all[i]).html().length;
if(typeof(tags[jQuery(all[i]).prop("tagName")]) == "undefined") {
@MattSandy
MattSandy / Candidate_Bigrams.png
Last active Aug 1, 2019
Candidate bigrams from the July 30th, 2019 Democratic Debate
@MattSandy
MattSandy / album_counts.R
Created Jul 26, 2019
Find the cumulative number of albums an artist has released and predict future counts.
View album_counts.R
# https://en.wikipedia.org/wiki/The_Mountain_Goats_discography
# Scraping
library("rvest")
library("ggplot2")
library("ggthemes")
library("stringr")
library("tidyverse")
tbls <- "https://en.wikipedia.org/wiki/The_Mountain_Goats_discography" %>%
read_html %>% html_nodes("table")
You can’t perform that action at this time.