Skip to content

Instantly share code, notes, and snippets.

View juliasilge's full-sized avatar
🐛

Julia Silge juliasilge

🐛
View GitHub Profile
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",
@juliasilge
juliasilge / qgraph.R
Created December 16, 2016 05:30 — forked from dgrtwo/qgraph.R
library(ggplot2)
library(igraph)
library(ggraph)
library(scales)
library(ggforce)
network_theme <- theme_no_axes() +
theme(panel.border = element_blank())
theme_set(network_theme)
simple_roc <- function(labels, scores){
labels <- labels[order(scores, decreasing=TRUE)]
data.frame(TPR=cumsum(labels)/sum(labels), FPR=cumsum(!labels)/sum(!labels), labels)
}
@juliasilge
juliasilge / density.R
Created July 13, 2016 13:38 — forked from noamross/density.R
Overlapping Density Plots
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) +
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")]
})