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),
---
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 / 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) +
#' ----------------------------------
#' Get simulated posterior fits from a gllvm
#' based on code from Francis KC Hui
#' with some light modifications by Jarrett Byrnes
#' ----------------------------------
require(mvtnorm)
require(tidyr)
require(dplyr)
#gllvm reprex on posthocs
library(palmerpenguins)
penguins <- na.omit(penguins)
Y <- with(penguins, data.frame(bill_length_mm, bill_depth_mm,
flipper_length_mm, body_mass_g))
X <- with(penguins, data.frame(species, sex))
@jebyrnes
jebyrnes / demo_gmailr.R
Created April 7, 2021 19:00
Analyze email traffic between two people and animate it
#'--------------------------------------------------
#' Script for gmail analysis between two people
#' using gmailr
#'--------------------------------------------------
library(gmailr)
library(tidyverse)
library(rties)
library(lubridate)
library(gganimate)
@jebyrnes
jebyrnes / power_curve_ggplot2.R
Created December 11, 2020 18:05
make a power curve with fitted data in ggplot2
library(dplyr)
g <- tibble(x = 1:10,
y = rnorm(10, x^(0.2), 0.05))
library(ggplot2)
mod <- lm(log(y) ~ log(x), data = g)