Skip to content

Instantly share code, notes, and snippets.

View njtierney's full-sized avatar
🐝
Back at work

Nicholas Tierney njtierney

🐝
Back at work
View GitHub Profile
pct_resupply <- tibble::tribble(
~Section, ~Days, ~`Distance.(mi)`, ~`Total.(mi)`, ~Resupply,
"Campo to Mt. Laguna", 3L, 42.9, 42.9, "B",
"Mt. Laguna to Warner Springs", 4L, 66.6, 109.5, "B",
"Warner Springs to Idyllwild", 5L, 69.9, 179.4, "B",
"Idyllwild to Big Bear City", 6L, 95.6, 275, "B",
"Big Bear City to Wrightwood", 6L, 94.5, 369.5, "B",
"Wrightwood to Agua Dulce", 6L, 85, 454.5, "B",
"Agua Dulce to Tehachapi or Mojave", 6L, 112, 566.5, "B",
"Tehachapi to Kennedy Meadows", 8L, 135.5, 702.2, "M",
clean_site_name_forbes <- function(site_name, out_name){
dplyr::case_when(
str_detect(site_name, "ST") ~ "STP Forbes",
str_detect(site_name, "Muddy") ~ "STP Forbes",
str_detect("ST", site_name) ~ "STP Forbes",
.default = "unmatched"
)
}
n.pixel <- 1000
n.other.spec <- 20
spec.names <- letters[1:(n.other.spec+1)]

## Geographic covariates affecting species abundance
x <- matrix(rnorm(2*n.pixel),nrow=n.pixel)

## Geographic covariate causing selection bias (correlated with x1)
z <- scale(x[,1] + rnorm(n.pixel)*sqrt(.95^(-2)-1))
library(polite)
library(tidyverse)
library(httr2)
library(rvest)
url <- "https://njt.micro.blog/2023/08/19/pct-day-kennedy.html"
extract_pct_summary <- function(url){
raw <- bow(url) %>% scrape()
raw %>%
library(tidyverse)

# 4 data sets
# survey
n <- 100
create_survey <- function(n, year, id = 1:n){
  tibble(
  id = id,
  year = year,
library(tidyverse)
# 4 data sets
# survey
n <- 100
create_survey <- function(n, year, id = 1:n){
tibble(
id = id,
year = year,
province = sample(1:9, size = n, replace = TRUE),
library(tidyverse)
cause_for_dismissal <- c("A",
                         "B",
                         "C")

vic_moz_long <- tibble(
  id = 1:5,
  species = c("B", "C", "D", "E", "F")
)
# comparison of Prem vs conmat for germany:

library(deSolve)
library(tidyverse)
library(conmat)
world_data <- socialmixr::wpp_age() %>%
  mutate(
    new_lower_age = if_else(lower.age.limit >= 75, 75L, lower.age.limit)
  ) %>%
library(distributional)
library(tidyverse)

dat <- tibble(
  id = 1:10,
  mean = c(1:10),
  sd = c(1:10)
) %>% 
  mutate(dist = dist_normal(
# ABS - what is statistically special about these numbers?
set_one <- c(5, 2, 7, 3, 5, 1)
set_two <- c(9, 6, 3, 5, 8, 6)

summary(set_one)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   1.000   2.250   4.000   3.833   5.000   7.000
summary(set_two)
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.