Skip to content

Instantly share code, notes, and snippets.

View juliasilge's full-sized avatar
💫

Julia Silge juliasilge

💫
View GitHub Profile
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")]
})
@juliasilge
juliasilge / blacklivesmatter.Rmd
Created July 7, 2016 19:01
flexdashboard exploring the WashPo fatal police shooting data set
---
title: "Fatal Police Shootings in the U.S."
output:
flexdashboard::flex_dashboard:
theme: flatly
social: menu
orientation: columns
vertical_layout: fill
---
@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) +
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 / 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)
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 / test_finance_text.R
Created November 8, 2017 02:55
Check out whether downloading/tidying financial text data is working
library(tm.plugin.webmining)
library(tidyverse)
library(tidytext)
company <- c("Microsoft", "Apple", "Google", "Amazon", "Facebook",
"Twitter", "IBM", "Yahoo", "Netflix")
symbol <- c("MSFT", "AAPL", "GOOG", "AMZN", "FB", "TWTR", "IBM", "YHOO", "NFLX")
download_articles <- function(symbol) {
WebCorpus(GoogleFinanceSource(paste0("NASDAQ:", symbol)))
@juliasilge
juliasilge / purrr_geniusR.R
Last active November 28, 2019 23:27
Beatles lyrics
library(tidyverse)
library(scales)
theme_set(silgelib::theme_plex())
library(geniusR)
library(tidytext)
albums <- tibble(artist = rep("The Beatles", 13),
album = c("Please Please Me",
"With the Beatles",
"A Hard Day's Night",
@juliasilge
juliasilge / january_meta.R
Last active January 27, 2019 23:14
Views to answers on Stack Overflow questions
## this analysis assumes a dataframe `post_views` with columns:
## PostId
## CreationDate
## Tag
## AnswerCount
## ViewCount
library(tidyverse)
post_views %>%

Keybase proof

I hereby claim:

  • I am juliasilge on github.
  • I am juliasilge (https://keybase.io/juliasilge) on keybase.
  • I have a public key ASDmuxcJrM55BGKWGxCENIRSHvzgkeXqhw61aiiVwcqMPQo

To claim this, I am signing this object: