monthly, upon BLS CPI release
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show all the function names in a given set of R scripts | |
function_definitions = function(files) { | |
purrr:::map(files, function_definitions_script) |> | |
purrr::list_rbind() | |
} | |
function_definitions_script = function(file) { | |
text = brio::read_lines(file) |> | |
paste(collapse = "\n") | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
year | cpi_u_rs_extended | |
---|---|---|
1937 | 24.3 | |
1938 | 23.8 | |
1939 | 23.5 | |
1940 | 23.6 | |
1941 | 24.9 | |
1942 | 27.6 | |
1943 | 29.2 | |
1944 | 29.7 | |
1945 | 30.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(MetricsWeighted) | |
# here's how to calculate multiple weighted percentiles by year | |
# and reshape them so data is long in year but wide in percentiles | |
# below I explain this step by step | |
# first grab some data | |
cps_data <- epiextractr::load_org(1979:2022, year, orgwgt, wage) %>% | |
filter(wage > 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(modelsummary) | |
library(kableExtra) | |
model_am1 = mtcars %>% | |
filter(am == 1) %>% | |
lm(mpg ~ wt, data = .) | |
model_am0 = mtcars %>% | |
filter(am == 0) %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* BEGIN BZ MODIFICATIONS */ | |
/* this do-file requires the following files from the authors | |
medicaidelig.dta | |
UKCPR_National_Welfare_Data_Update_021520.dta | |
*/ | |
copy https://github.com/Economic/state_geocodes/raw/master/state_geocodes.dta state_geocodes.dta, replace | |
use state_geocodes, clear | |
rename state_census stcps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(ggridges) | |
# state codes | |
states_regions <- read_csv("https://raw.githubusercontent.com/cphalpert/census-regions/master/us%20census%20bureau%20regions%20and%20divisions.csv") %>% | |
select(state_abb = `State Code`, region = Region) | |
# CMS provider info | |
# https://data.cms.gov/provider-data/dataset/4pq5-n9py | |
raw <- read_csv("NH_ProviderInfo_Jun2023.csv") %>% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(lubridate) | |
library(hrbrthemes) | |
# K-12 shooting incident data from https://www.chds.us/ssdb/data-map/ | |
readxl::read_excel("SSDB_Raw_Data.xlsx", sheet = "INCIDENT") %>% | |
mutate( | |
year = year(ymd(Date)), | |
month = month(ymd(Date)), | |
month_date = ym(paste(year, month)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(lubridate) | |
library(haven) | |
library(assertr) | |
library(slider) | |
library(hrbrthemes) | |
# function to bin hourly wages of hourly workers | |
bin_hourly <- function(df, new, old) { | |
df %>% |
NewerOlder