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
# Geocoding a csv column of "addresses" in R | |
#load ggmap | |
library(ggmap) | |
# Select the file from the file chooser | |
fileToLoad <- file.choose(new = TRUE) | |
# Read in the CSV data and store it in a variable | |
origAddress <- read.csv(fileToLoad, stringsAsFactors = FALSE) |
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
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() |
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(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")) |
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(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")) %>% |
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
/* A Spreadsheet-powered Twitterbot Engine, version 0.4, May 2015 | |
by Zach Whalen (@zachwhalen, zachwhalen.net, etc.) | |
This code powers the backend for a front-end in a google spreadsheet. If somehow you've arrived at this code without the spreadsheet, start by making a copy of that sheet by visiting this link: | |
bit.ly/botsheet | |
All of the setup instructions are available in the sheet or (with pictures!) in this blog post: | |
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(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) |
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(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") |
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(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() |
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
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", |
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(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) |
NewerOlder