Skip to content

Instantly share code, notes, and snippets.

def score_calculation(weights, school, district):
'''
district is a list of census blocks which we are including on the district
school is a specific school id
the weights normalize the scores taking into account their relative importance
'''
# population of district and minority population from global DataFrame block_data
pop = block_data['HS_POP'].loc[district].sum()
minority_pop = block_data['MINORITY'].loc[district].sum()
library(rvest)
library(tidyRSS)
library(tidyverse)
library(stringr)
# https://www.cjr.org/analysis/as-election-looms-a-network-of-mysterious-pink-slime-local-news-outlets-nearly-triples-in-size.php
pinkslimesites <- read.csv("pinkslimesites.csv", stringsAsFactors = F)
all_pinkslimesites <- pinkslimesites %>%
mutate(Rss = paste0(Domain,"/stories.rss"))
library(tidyverse)
library(rtweet)
library(twinetverse)
JimJordan <- search_tweets2("https://twitter.com/Jim_Jordan/status/1257813096707641346", n = 15000, include_rts = T)
glimpse(JimJordan)
JimJordan <- JimJordan %>%
mutate(maga_label = str_detect(description, "MAGA")) %>%
library(data.table)
library(dplyr)
library(R.utils)
# JUST MASS
mass <- gunzip("arcos-ma-statewide-itemized.tsv.gz")
mass_opioids <- fread(file = 'arcos-ma-statewide-itemized.tsv')
glimpse(mass_opioids) # 2,574,240 observations
summary(mass_opioids)
library(tidyverse)
library(leaflet)
library(geojsonio)
library(htmlwidgets)
library(htmltools)
nycmarkers <- read.csv("nycmarkers.csv", stringsAsFactors=F) # with "lat", "lon" and "string" columns
nycshapefile <- geojsonio::geojson_read("nycshapefile.geojson", what = "sp")
library(dplyr)
library(tidyverse)
library(tidytext)
library(plotly)
library(stringr)
# Pull in spreadsheet
df <- read.csv("fbads.csv", header=TRUE, stringsAsFactors = FALSE)
df$date <- as.Date(df$created_at) # Add date column
df %>% glimpse()
var fs = require("fs");
var table = read_table("data/hurdat2-1851-2017-050118.txt", ",");
var curr_obj,
curr_entry_count;
var data = [],
geojson = {
"type": "FeatureCollection",
library(tidyverse)
library(ggplot2)
dataset <- read.csv("winemag-data.csv",
header=TRUE, stringsAsFactors=FALSE)
dataset %>% glimpse(102)
# Quick view and descriptive stats
min(dataset$points)
max(dataset$points)
library(ggplot2)
library(tidyverse)
library(fiftystater)
mapdata <- read.csv("state-medal-count.csv", header=TRUE, stringsAsFactors=FALSE)
mapdata %>% glimpse()
data("fifty_states")
ggplot() + geom_polygon( data=fifty_states, aes(x=long, y=lat, group = group),color="white", fill="grey10" )
import csv
import requests
import threading
import os
import sys
from Queue import Queue
from bs4 import BeautifulSoup as bs
# Globals
q = Queue()