Skip to content

Instantly share code, notes, and snippets.

View jebyrnes's full-sized avatar

Jarrett Byrnes jebyrnes

View GitHub Profile
@jebyrnes
jebyrnes / sublinear.r
Created March 18, 2024 15:52
playing with sublinear growth rate
#sublinear
library(deSolve)
# adapted from
# https://hankstevens.github.io/Primer-of-Ecology/DDgrowth.html
sublinear <- function(t, y, p){
bi <- y[1]
dN.dt <- with(as.list(p),
r*b0^(1-k)*bi^k - z*bi
---
title: "test"
format: revealjs
---
# DAG Before You Model
[Which of these is your model?]{.center}
::: {.columns}
library(dplyr)
library(piecewiseSEM)
make_tests <- function(){
dat <- tibble(
x <- runif(100),
x1 = rnorm(100, x, sd = 0.001),
x2 = rnorm(100, x, sd = 0.001),
x3 = runif(100),
y1 = rnorm(100, x1 + x3, sd = 0.1),
@jebyrnes
jebyrnes / bayesian_posthoc.R
Last active February 10, 2023 20:29
Posthoc contrasts with emmeans, tidybayes, and brms
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
---
title: "1. How to work with satellite data in R"
output:
html_document:
df_print: paged
---
This tutorial will show the steps to grab data in ERDDAP from R, how to work with NetCDF files in R and how to make some maps and time-series of sea surface temperature (SST) around the main Hawaiian islands.
@jebyrnes
jebyrnes / chatbot_ai_rnoaa_pp.r
Created December 4, 2022 21:59
A shiny app by chat.openai.com to make clickable maps of all noaa buoys that fetches sea surface temperature.
library(shiny)
library(rnoaa)
library(leaflet)
ui <- fluidPage(
leafletOutput("map"),
plotOutput("tempPlot")
)
server <- function(input, output) {
@jebyrnes
jebyrnes / leafletMap.R
Last active August 8, 2022 14:13
Basic leaflet mapping in R
#Load the library and make a basic map
library(leaflet)
leaflet() %>% addTiles()
#Show a map with a satellite picture on it
leaflet() %>%
addTiles(urlTemplate="http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}")
#Make a demo fake data set
@jebyrnes
jebyrnes / geom_labelsmooth_penguins.R
Created February 9, 2022 15:12
playing with geomtextpath
library(palmerpenguins)
library(ggplot2)
library(geomtextpath)
ggplot(penguins,
aes(x = body_mass_g, y = flipper_length_mm,
color = species, label = species)) +
geom_point(alpha = 0.2) +
geom_labelsmooth(method = "lm", boxlinewidth = 0) +
@jebyrnes
jebyrnes / sims3.r
Created May 19, 2011 17:35
Simulations of beta regression as compared to other techniques designed for working on response variables on a unit (0,1) scale.
######
#script to generate simulations comparing the power and type I error rate
#of a variety of different methods of analyzing response variables on a unit (0-1) scale
#
# Inspired by "The Arcsine is Asinine" in a 2011 issue of Ecology
#
# byrnes@nceas.ucsb.edu
# last updated 5/19/11
#
# Changelog: Added visualization code
#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)