View tay_distribution.R
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
## Imports ---- | |
library(tidyverse) | |
library(genius) | |
library(here) | |
library(fs) | |
data("stop_words") | |
source("https://raw.githubusercontent.com/mkiang/airline_testing_strategies/master/code/mk_nytimes.R") | |
dir_create(here("data")) |
View 01_pull_data.R
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
## Visualizing authorship networks: code for this blog post: | |
## https://mathewkiang.com/2020/12/10/my-collaboration-network-for-2010-to-2020-other-plots | |
## Imports ---- | |
library(scholar) # remotes::install_github("jkeirstead/scholar") | |
library(tidyverse) | |
library(fs) | |
library(here) | |
## Constants ---- |
View c19_vs_topten.R
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(ggrepel) | |
library(zoo) | |
source("https://raw.githubusercontent.com/mkiang/opioid_geographic/master/code/mk_nytimes.R") | |
## 2018 top causes of death: | |
## https://www.cdc.gov/nchs/fastats/deaths.htm | |
nchs_df <- tribble(~ cause, ~ deaths_2018, | |
"1.Heart disease", 655381, | |
"2. Cancer", 599274, |
View clean_tweets.R
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 quick R script for cleaning up your Twitter timeline. This assumes you | |
## have Twitter API creds but it probably isn't necessary. This is based on | |
## Chris Albon's Python script: | |
## https://gist.github.com/chrisalbon/b9bd4a6309c9f5f5eeab41377f27a670 | |
## | |
## In this example, I remove old tweets in two stages: (1) if tweets are | |
## older than two years and have fewer than 100 likes and then (2) if tweets | |
## are older than 90 days and have fewer than 25. Retweets are removed after | |
## 90 days. Importantly, tweets (and retweets) that I liked are *always* | |
## protected from deletion. |
View DJI_inter_peak_days.R
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(tidyquant) | |
source( | |
"https://raw.githubusercontent.com/mkiang/disproportionate_prescribing/master/code/mk_nytimes.R" | |
) | |
getSymbols("^DJI") | |
DJI <- as_tibble(DJI) %>% | |
mutate( |
View 01_pull_data.R
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
## Visualizing authorship networks: code for this blog post: | |
## https://mathewkiang.com/2019/12/07/collaboration-network-from-2010-to-2019/ | |
## Imports ---- | |
library(scholar) # remotes::install_github("jkeirstead/scholar") | |
library(tidyverse) | |
library(fs) | |
library(here) | |
## Constants ---- |
View intro_sir.R
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
## Import packages | |
library(deSolve) | |
## Basic SIR using number of people (not proportion of pop) | |
SIR <- function(t, x, parms){ | |
with(as.list(c(parms, x)), { | |
N = S + I + R | |
dS <- -beta*S*I/N | |
dI <- beta*S*I/N - r*I | |
dR <- r*I |
View packages.R
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
install.packages("rgdal", dep = TRUE) | |
install.packages("reshape2", dep = TRUE) | |
install.packages("viridis", dep = TRUE) | |
install.packages("rgeos", dep = TRUE) | |
install.packages("Imap", dep = TRUE) | |
install.packages("network", dep = TRUE) | |
install.packages("DT", dep = TRUE) | |
install.packages("tidyverse", dep = TRUE) | |
install.packages("deSolve", dep = TRUE) | |
install.packages("manipulate", dep = TRUE) |
View collab_network.R
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
## Visualizing authorship networks: code for this blog post: | |
## https://mathewkiang.com/2018/06/17/my-collaboration-network/ | |
library(scholar) # devtools::install_github("jkeirstead/scholar") | |
library(visNetwork) | |
library(tidyverse) | |
## Constants | |
MIN_TIME <- 60 * 5 | |
MAX_TIME <- 60 * 30 | |
PROJ_WEIGHT <- .8 |
View 01_get_data.R
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
## For blog post here: https://mathewkiang.com/2017/12/02/tldr-san-diego-weather-is-better-than-boston-weather/ | |
## Imports ---- | |
library(tidyverse) | |
library(GSODR) | |
library(ggmap) | |
## Define places we are interested in and google maps query ---- | |
city_dict <- list(sandiego = "san diego airport", |
NewerOlder