Skip to content

Instantly share code, notes, and snippets.

@andrewbtran
andrewbtran / covid19_disparity_early.Rmd
Last active Apr 8, 2020
coronavirus county and regional disparity analysis
View covid19_disparity_early.Rmd
---
title: "Coronavirus racial disparities"
author: "Andrew Ba Tran and Reis Thebault"
date: "4/7/2020"
output:
html_document:
code_folding: hide
---
Counties where Black residents are the majority have three times the rate of median cases of coronavirus cases and have almost four times the average rate of deaths of counties.
View covidtracking_table.R
# This function checks if you don't have the correct packages installed yet
# If not, it will install it for you
packages <- c("tidyverse", "jsonlite", "data.table", "formattable", "scales", "knitr")
if (length(setdiff(packages, rownames(installed.packages()))) > 0) {
install.packages(setdiff(packages, rownames(installed.packages())), repos = "http://cran.us.r-project.org")
}
# packages necessary
library(tidyverse)
library(jsonlite)
View keybase.md

Keybase proof

I hereby claim:

  • I am andrewbtran on github.
  • I am trana (https://keybase.io/trana) on keybase.
  • I have a public key ASAMUjcvhuYo-gflVNYHlsAzAXhR8uH3Ge2NvwOjh7TDMAo

To claim this, I am signing this object:

@andrewbtran
andrewbtran / nlpp.r
Last active Dec 16, 2019
NiemanLab Predictions Predictor
View nlpp.r
# Load libraries
library(dplyr)
library(rvest)
devtools::install_github("abresler/markovifyR")
library(markovifyR)
# The url for the 2019 predictions
year2019 <- "https://www.niemanlab.org/collection/predictions-2019"
@andrewbtran
andrewbtran / gsiterator.R
Created Jun 19, 2019
gsiterator template
View gsiterator.R
library(tidyverse)
library(googlesheets)
# Authorize user on Google
gs_auth(new_user = TRUE)
# Naming the sheet
name_of_googlesheet <- "Testing out gsiterator"
# Test array
@andrewbtran
andrewbtran / gist:4bf3d8dd7a0f443f4888a31eaa7fff1b
Created Apr 29, 2019
Game of Thrones death pool (week 3 results)
View gist:4bf3d8dd7a0f443f4888a31eaa7fff1b
library(tidyverse)
responses <- read_csv("https://docs.google.com/spreadsheets/d/e/2PACX-1vT7yj6UE0S08spLamewjnZH1vbOCqobyRSEao5I535XvgO9VeM_fwe-P84_9oiPAuQsfd5rYyncNuax/pub?output=csv")
week3 <- data.frame(c("Theon Greyjoy",
"Melisandre",
"Jorah Mormont",
"Edd Tollett",
"Lyanna Mormont",
"Beric Dondarrion (can select multiple eps for death)
@andrewbtran
andrewbtran / financial-disclosure.R
Created Aug 31, 2018
Scraping WH financial disclosures
View financial-disclosure.R
library(tidyverse)
library(rvest)
page <- xml2::read_html("https://extapps2.oge.gov/201/Presiden.nsf/PAS%20Filings%20by%20Date?OpenView")
tbl <- html_table(page)[[1]]
tbl <- as_tibble(tbl)
names(tbl) <- c("date", "report", "name", "department", "position")
tbl
View top_1_percent
# File # 1
# https://drive.google.com/open?id=1Lhz23JP4gRW4p_01D7OzaL60CT1wfem-
# File # 2
# https://drive.google.com/open?id=1XOWD8COTdDx30HNLZgrp57WzWUGOtaKA
# NOTE: To load data, you must download both the extract's data and the DDI
# and also set the working directory to the folder with these files (or change the path below).
#install.packages("tidyverse")
View gist:8507f79e0ded054ac2b38878f94063dc
library(jsonlite)
library(tidyr)
schools_list <- fromJSON("http://neworleansequityindex.org/jsoncache/schools.json")
schools_list <- schools_list$data
# for loop
# for i in 1 through number of rows of the dataframe schools_list
View Chunk 7
---
title: "Chunk 7"
author: "Andrew"
date: "3/10/2018"
output:
html_document:
toc: true
toc_float: true
---