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 / 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 / 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)
@jebyrnes
jebyrnes / raster_fade.R
Created Feb 20, 2019
crossfading between raster layers in gganimate
View raster_fade.R
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 Feb 1, 2019
A little animation of Bayesian updating with a
View bayesian_updating.R
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 Jan 23, 2019
Quick reprex for @ jess_carilli
View same_model_many_responses.R
#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
@jebyrnes
jebyrnes / geospatial_test.R
Last active Jan 22, 2019
Try this and make sure there are no errors. If it all runs, you're in good shape! Should make three plots, and install rnaturalearth, which is pretty cool
View geospatial_test.R
#'------------------------------
#'
#' Script to make sure everything works
#' for you for the 2019-01-22 Geospatial
#' Data Carpentry workshop at UMB
#'------------------------------
# Make sure we have rnaturalearth installed
# If you do, comment out the install.packages line
#or just don't run it.
@jebyrnes
jebyrnes / threshold_classifications_sf.R
Created Jan 3, 2019
Makes thresholded sf multipolygons from user classifications for floating forests with a sample data set
View threshold_classifications_sf.R
library(sf)
library(fasterize)
library(spex)
library(dplyr)
library(purrr)
library(ggplot2)
library(lwgeom)
test_set <- devtools::source_gist("c95701bd444cda3e342838fd9a090fb3",
@jebyrnes
jebyrnes / test_set.R
Created Jan 2, 2019
a sample sf multipolygon set
View test_set.R
structure(list(classification_id = c(82289537L, 82386012L, 84461998L,
85718077L, 91018956L, 102059723L, 102656990L, 103374144L, 105820504L,
108510525L, 113891667L, 120531542L, 133372372L, 133644897L, 134776350L
), geometry = structure(list(structure(list(structure(list(structure(c(314658.101094576,
314658.101094576, 314637.103677284, 314616.106259993, 314616.106259993,
314595.108842701, 314595.108842701, 314574.111425409, 314553.114008117,
314553.114008117, 314532.116590825, 314532.116590825, 314511.119173533,
314511.119173533, 314511.119173533, 314511.119173533, 314511.119173533,
314511.119173533, 314511.119173533, 314532.116590825, 314532.116590825,
314553.114008117, 314574.111425409, 314595.108842701, 314616.106259993,
You can’t perform that action at this time.