Skip to content

Instantly share code, notes, and snippets.

View jebyrnes's full-sized avatar

Jarrett Byrnes jebyrnes

View GitHub Profile
@jebyrnes
jebyrnes / biking.R
Created November 5, 2019 19:10
A quick interactive map of biking for #tidytuesday
library(tidyverse)
library(ggmap)
library(sf)
library(tmap)
#whereami?
here::here()
#get my apis flowin'
register_google(readLines("~/goog.api"))
@jebyrnes
jebyrnes / chanty_analysis.R
Last active October 25, 2019 18:08
Some tidytext anaylysis of sea chanties
library(tidyverse)
library(tidytext)
library(rvest)
library(ggplot)
#get the initial info from the site
site <- "http://www.guscantieni.com/bindarrr/"
index <- read_html(paste0(site, "index.html"))
#Rayshader reprex to try and put a flat raster map under a
#set of 3d points
library(rayshader)
library(ggplot2)
library(dplyr)
library(maps)
library(ggmap)
data(world.cities)
@jebyrnes
jebyrnes / tidy_foodweb.R
Created May 14, 2019 21:24
Playing around with tidygraph, ggraph, and NetIndices to draw food webs
#see also https://davidsmale.netlify.com/portfolio/wes-anderson-actor-network/
# https://www.data-imaginist.com/2017/introducing-tidygraph/
# https://www.jessesadler.com/post/network-analysis-with-r/
#load libraries
library(rglobi)
library(tidygraph)
library(ggraph)
library(NetIndices)
@jebyrnes
jebyrnes / spatial_causality.R
Last active May 8, 2019 15:35
Looking at spatial lags and anomolies to see if they work out like temporal anomolies/fixed effect models
library(spdep)
library(spatialreg)
library(SpatialTools)
library(dplyr)
library(nlme)
library(mgcv)
library(purrr)
library(stringr)
library(ggplot2)
library(broom)
@jebyrnes
jebyrnes / gam_v_cor.R
Created April 8, 2019 19:13
Does a gam act like a fixed effect for autocorrelation?
library(MASS)
library(tidyverse)
library(ggplot2)
library(mgcv)
gaussprocess <- function(from = 0, to = 1, K = function(s, t) {min(s, t)},
start = NULL, m = 1000) {
# Simulates a Gaussian process with a given kernel
#
# args:
library(heatwaveR)
library(tsibble)
library(lubridate)
library(dplyr)
# Detect the events in a time series
ts <- ts2clm(sst_WA, climatologyPeriod = c("1982-01-01", "2011-12-31"))
mhw <- detect_event(ts, minDuration = 1, maxGap = 0)
@jebyrnes
jebyrnes / raster_fade.R
Created February 20, 2019 05:11
crossfading between raster layers in gganimate
library(ggplot2)
library(gganimate)
mygridstart <- tidyr::crossing(x = 1:10, y = 1:10)
mygrid <- rbind(mygridstart, mygridstart, mygridstart)
mygrid$rep <- sort(rep(1:3, nrow(mygrid)/3))
mygrid$pointgroup <- rep(1:100, 3)
mygrid$f <- factor(sample(1:3, replace=TRUE, size = nrow(mygrid)))
@jebyrnes
jebyrnes / bayesian_updating.R
Created February 1, 2019 15:49
A little animation of Bayesian updating with a
library(dplyr)
library(tidyr)
library(stringr)
library(ggplot2)
library(gganimate)
#make those samples!
set.seed(3003)
samps <- replicate(9, rbinom(1,1,prob = 0.3))
running_samps <- cumsum(samps)
@jebyrnes
jebyrnes / same_model_many_responses.R
Created January 23, 2019 15:16
Quick reprex for @ jess_carilli
#some libraries
library(dplyr)
library(tidyr)
library(broom)
library(purrr)
#let's use the npk data
head(npk)
#but make up a few extra columns