# using distributional
options(tidyverse.quiet = TRUE)
library(tidyverse)
library(distributional)
dat_dist <- tibble(
means = c(1:5),
sds = c(5:1),
vals = means + rnorm(5, 0.1, 0.1),
View using-distributional.md
View pct-resupply.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", |
View example-case-when.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
) | |
} |
View reprex-multidsm.md
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))
View scrape-pct-blog.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %>% |
View demo-join.md
library(tidyverse)
# 4 data sets
# survey
n <- 100
create_survey <- function(n, year, id = 1:n){
tibble(
id = id,
year = year,
View joins-demo-sim.R
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), |
View matches-and-things.md
library(tidyverse)
cause_for_dismissal <- c("A",
"B",
"C")
vic_moz_long <- tibble(
id = 1:5,
species = c("B", "C", "D", "E", "F")
)
View conmat-v-prem.md
# 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)
) %>%
View distributions.md
library(distributional)
library(tidyverse)
dat <- tibble(
id = 1:10,
mean = c(1:10),
sd = c(1:10)
) %>%
mutate(dist = dist_normal(
NewerOlder