This file contains 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(acs) | |
library(dplyr) | |
library(ggplot2) | |
zips <- acs::geo.make(zip = "*") | |
# Get median household income. | |
income <- | |
acs::acs.fetch( | |
endyear = 2014, span = 5, |
This file contains 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
# Clear. Dat. Workspace. | |
rm(list = ls()) | |
# Load. Dem. Packages. | |
library(tidyverse) | |
# Create. Dat. Data. | |
dat <- data.frame(category = LETTERS[1:4], | |
fraction = c(0, 20, 30, 50)) # Extra zero datapoint to keep hole in the donut. |
This file contains 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
# Load packages ---- | |
library(tidyverse) | |
library(RcppRoll) | |
library(scales) | |
# Create three different headcount growth models ---- | |
dates <- seq.Date(as.Date("2006-01-01"), as.Date("2018-12-31"), by = "day") %>% | |
tibble::tibble(daily_date = ., t = 1:length(.)) %>% | |
dplyr::mutate( | |
month_begin_date = lubridate::floor_date(daily_date, unit = "month") |
This file contains 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
# Load packages ---- | |
library(tidyverse) | |
# Create US-state-level headcount dataset ---- | |
business_markets <- tibble::tribble( | |
~city_name, ~state_name, ~mean_headcount, | |
"Austin", "TX", 8, | |
"Denver", "CO", 22, | |
"Los Angeles", "CA", 97, | |
"Minneapolis", "MN", 7, |
This file contains 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
sample_list <- list(rnorm(1000, 0, 1)) | |
mean_vec <- c(mean(sample_list[[1]])) | |
sd_vec <- c(sd(sample_list[[1]])) | |
chains <- tibble::tibble(chain = rep, | |
mean_value = NA, | |
sd_value = NA) | |
for (i in 2:100000) { | |
sample_list[[i]] <- rnorm(1000, mean_vec[i - 1], sd_vec[i - 1]) | |
mean_vec[i] <- mean(sample_list[[i]]) | |
sd_vec[i] <- sd(sample_list[[i]]) |