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(tidycensus) | |
library(tidyverse) | |
# If not set, un-comment below and install your Census API key (https://api.census.gov/data/key_signup.html) | |
# census_api_key("YOUR KEY HERE", install = TRUE) | |
get_acs(geography = "metropolitan statistical area/micropolitan statistical area", | |
variables = "DP03_0021PE", | |
summary_var = "B01003_001", | |
survey = "acs1", |
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(ggplot2) | |
library(igraph) | |
library(ggraph) | |
library(scales) | |
library(ggforce) | |
network_theme <- theme_no_axes() + | |
theme(panel.border = element_blank()) | |
theme_set(network_theme) |
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
simple_roc <- function(labels, scores){ | |
labels <- labels[order(scores, decreasing=TRUE)] | |
data.frame(TPR=cumsum(labels)/sum(labels), FPR=cumsum(!labels)/sum(!labels), labels) | |
} |
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(dplyr) | |
library(tidyr) | |
library(ggplot2) | |
library(gridExtra) | |
df = data_frame(a = rnorm(100, mean=1), b=rnorm(100, mean=2), c=rnorm(100, mean=0)) %>% | |
gather("var", "value", a,b,c) | |
ggplot(df, aes(x=value)) + | |
geom_density(fill="black", col="white", lwd=1) + |
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
purrr::map_df(2009:2014, function(i) { | |
api_info <- jsonlite::fromJSON(sprintf("http://api.census.gov/data/%s/acs5/", i)) | |
api_info$dataset[, c("title", "c_unavailableMessage")] | |
}) |