Skip to content

Instantly share code, notes, and snippets.

@saveyak
saveyak / rcheatsheet.R
Created November 9, 2022 19:25
R Cheatsheet
####Useful libraries####
library(ggplot2) #Other standards: dplyr, aptheme, lubridate
install.packages('tidyverse')
library(DT) #Create searchable datatable
datatable(mtcars)
library(ggplot2)
library(tidyverse)
library(aptheme)
library(readxl)
library(readr)
@saveyak
saveyak / acs_singles.r
Last active February 11, 2022 15:50
Find ratio of single men and single women by state
#Purpose: Analyze rates of single people by age/sex
library(tidyverse)
library(tidycensus)
#### Reference Material ####
#https://stackoverflow.com/questions/46665004/r-use-str-extract-stringr-to-export-a-string-between
#https://stackoverflow.com/questions/8161836/how-do-i-replace-na-values-with-zeros-in-an-r-dataframe
#https://stackoverflow.com/questions/25372082/create-column-based-on-presence-of-string-pattern-and-ifelse
library(tidyverse)
library(readxl)
#Notes:
#Excel file from here, "Child Tax Credit Table": https://www.census.gov/data/tables/2021/demo/hhp/hhp39.html
#Headers:
#Category = Spending category
#Total = total number of adults
#CTC_spent = total number of adults in households that received a child tax credit in the last four weeks and reported that they mostly spent it
#CTC_saved = received credit and mostly saved it
@saveyak
saveyak / arts_education_NOLA.R
Created February 25, 2021 16:41
Arts Education in New Orleans
#I wrote this code to produce the graphics used in the public policy report, "Will the Arts Come Marching In? Access to Arts Education in Post-Katrina New Orleans," by Sarah Woodward of Tulane University. Read the report here: https://educationresearchalliancenola.org/files/publications/20200915-Woodward-Will-the-Arts-Come-Marching-in-Access-to-Arts-Education-in-Post-Katrina-New-Orleans.pdf
library(readxl)
library(tidyverse)
library(ggplot2)
library(extrafont)
library(scales)
library(grid)
library(stringr) #lets you use str_wrap()
@saveyak
saveyak / restraint_scrape.ipynb
Created September 16, 2020 00:28
Using Python's Tika package to read hundreds of pages of PDFs and create a dataframe
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saveyak
saveyak / powerlifting.r
Created October 17, 2019 18:03
#TidyTuesday Week 41: Powerlifting
#Tidy Tuesday: Powerlifting
#https://github.com/rfordatascience/tidytuesday/tree/master/data/2019/2019-10-08
#Powerlifting data from 1973 to 2019
setwd("C:/Users/Sharon/Documents/Data/tidy_tuesday")
library(readr)
library(tidyverse)
library(lubridate)
options(scipen = 1000)