Skip to content

Instantly share code, notes, and snippets.

Jarrett Byrnes jebyrnes

Block or report user

Report or block jebyrnes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jebyrnes
jebyrnes / meow_plot_base.R
Last active Oct 2, 2019
Basic methods for dealing with shapefiles for marine ecoregions of the world.
View meow_plot_base.R
#########################################################################
# Code to import and make useful
# Spalding et al. 2007's Marine Ecoregions of the World
# Data provided by http://www.marineregions.org/downloads.php
# by Jarrett Byrnes
# last updated 3/26/2015
#########################################################################
######################
##### Load Libraries
@jebyrnes
jebyrnes / bayesian_posthoc.R
Last active Sep 25, 2019
Posthoc contrasts with emmeans, tidybayes, and brms
View bayesian_posthoc.R
library(tidyverse)
library(emmeans)
library(brms)
library(tidybayes)
warp.brms <- brm(breaks ~ wool * tension, data = warpbreaks)
#get the adjusted means
warp_em <- emmeans (warp.brms, ~ tension | wool)
warp_em
@jebyrnes
jebyrnes / had_crut_spider_plot.R
Created May 13, 2016
R code to reproduce the awesome visualization of global temperature change from Ed Hawkins at http://www.climate-lab-book.ac.uk/2016/spiralling-global-temperatures/ using R and ggplot2 (with the animations package)
View had_crut_spider_plot.R
library(dplyr)
library(tidyr)
library(ggplot2)
library(animation)
#Data from https://crudata.uea.ac.uk/cru/data/temperature/
#As well as data read in script
source("read_cru_hemi.R")
temp_dat <- read_cru_hemi("./HadCRUT4-gl.dat")
#remove cover
View rayshade_maps_gg.R
#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
Playing around with tidygraph, ggraph, and NetIndices to draw food webs
View tidy_foodweb.R
#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
Looking at spatial lags and anomolies to see if they work out like temporal anomolies/fixed effect models
View spatial_causality.R
library(spdep)
library(spatialreg)
library(SpatialTools)
library(dplyr)
library(nlme)
library(mgcv)
library(purrr)
library(stringr)
library(ggplot2)
library(broom)
@jebyrnes
jebyrnes / glm_profile.R
Last active Apr 22, 2019
Take a glm and creates a deviance profile, as MASS::profile only returns a transformed version of the deviance.
View glm_profile.R
library(ggplot2)
#A glm from the glm helpfile
counts <- c(18,17,15,20,10,20,25,13,12)
outcome <- gl(3,1,9)
treatment <- gl(3,3)
print(d.AD <- data.frame(treatment, outcome, counts))
glm.D93 <- glm(counts ~ outcome + treatment, family = poisson())
#The old way...
@jebyrnes
jebyrnes / rethinking_measurement_errors.R
Created Nov 27, 2016
Rethinking Measurement Error - models using the rethinking package that incorporate measurement in both the response and predictor variables.
View rethinking_measurement_errors.R
library(rethinking)
library(dplyr)
data(WaffleDivorce)
mod <- alist(
#likelihood
div_est ~ dnorm(mu, sigma),
#model
@jebyrnes
jebyrnes / gam_v_cor.R
Created Apr 8, 2019
Does a gam act like a fixed effect for autocorrelation?
View gam_v_cor.R
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:
View spike_wave.R
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)
You can’t perform that action at this time.