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(rstanarm) | |
library(simsurv) | |
?stan_surv | |
data("frail") | |
m_frail <- stan_surv( | |
formula = Surv(eventtime, status) ~ trt + (1 | site), | |
data = frail[1:40,], |
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
# set colours for plot | |
colours <- RColorBrewer::brewer.pal(10, 'Spectral') | |
# function to make points lighter but not transparent | |
alpha_hex <- function(hex_code, alpha = 1){ | |
# split by ',' and extract number | |
temp <- monochromeR::hex_to_rgb(hex_code) %>% | |
str_split(., ',') %>% | |
.[[1]] %>% | |
parse_number() |
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
# have a look at whether having multiple 0 values impacts the results of model fitting to TPCs | |
# load libraries | |
librarian::shelf(rTPC, nls.multstart, tidyverse, broom) | |
# simulate data using Sharpe Schoolfield model | |
d_simulate <- tibble(temp = seq(from = 10, to = 55, length.out = 10), | |
rate = sharpeschoolhigh_1981(temp = temp, r_tref = 0.5, e = 0.6, eh = 5, th = 33, tref = 17.5)) %>% | |
# add noise | |
mutate(noise = rnorm(n(), 0, 0.1), |
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
# try write script to extract data/code accessibility statement | |
# try with BES journals first. The trick is in grabbing the correct node (whatever that is) | |
mee_url <- 'https://doi.org/10.1111/2041-210X.13585' | |
functionalecology_url <- 'https://doi.org/10.1111/1365-2435.14422' | |
animalecology_url <- 'https://doi.org/10.1111/1365-2656.13983' | |
appliedecology_url <- 'https://doi.org/10.1111/1365-2664.14474' | |
# library | |
library(rvest) |
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
# random flextable example to put a symbol in a column | |
librarian::shelf(tidyverse, flextable, officer) | |
data(mpg) | |
# copyright symbol | |
copyright_symbol <- "\U00A9" | |
black_dot <- "\U2B24" |
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
# nimble and tidybayes example | |
# load packages | |
librarian::shelf(tidybayes, nimble, tidyverse, bayesplot, ggdist, nlist) | |
# run example from runMCMC | |
code <- nimbleCode({ | |
mu ~ dnorm(0, sd = 1000) | |
sigma ~ dunif(0, 1000) |
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
# example of using cowplot and patchwork to make a plot with legends in the bottom right of a four panel plot | |
# load in packages | |
librarian::shelf(tidyverse, patchwork, cowplot) | |
# make a random plot with colour | |
p1 <- ggplot(mpg, aes(hwy, cty, col = class)) + | |
geom_point() | |
# make other plot with colour on |
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
# try weighted bootstrapping of many curves | |
# combines approach from weighted bootstrapping and bootstrapping many curves | |
# https://padpadpadpad.github.io/rTPC/articles/bootstrapping_many_curves.html | |
# https://padpadpadpad.github.io/rTPC/articles/weighted_bootstrapping.html | |
# load in packages | |
librarian::shelf(tidyverse, rTPC, nls.multstart, broom, minpack.lm, car) | |
# load in data | |
data("chlorella_tpc") |
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
# example of using cowplot and patchwork to make a plot with legends in the bottom right of a four panel plot | |
# load in packages | |
librarian::shelf(tidyverse, patchwork, cowplot) | |
# make a random plot with colour | |
p1 <- ggplot(mpg, aes(hwy, cty, col = class)) + | |
geom_point() | |
# make other plot with colour on |
NewerOlder