## ----setup, include = FALSE--------------------------------------------------- knitr::opts_chunk$set( collapse = TRUE, comment = "#>", warning = FALSE, message = FALSE, fig.width = 10, fig.height = 5.5 ) ## ----data--------------------------------------------------------------------- library(ascent) # birds_sim is loaded with the package traits <- birds_sim$traits # species x traits (categorical traits as factors) counts <- birds_sim$counts # surveys x species, counts of individuals samples <- birds_sim$samples # site and time of each survey head(traits) table(samples$site, samples$time) ## ----space-------------------------------------------------------------------- assess_functional_space(traits) ## ----paired------------------------------------------------------------------- res <- asc_paired(traits, counts, sites = samples$site, time = samples$time, ref_time = "Before") res <- asc_null(res, n_perm = 199, seed = 1) summary(res) ## ----paired_table, echo = FALSE----------------------------------------------- nm <- res$null_models pos <- nm[nm$Layer == "Position", c("Contrast", "Test", "SES", "P_upper", "P_lower")] ## ----transitions-------------------------------------------------------------- tr <- asc_transitions(res) summary(tr, n_sp = 5) plot(res, contrast = "Logged", type = "both", n_sp = 5) ## ----entities, fig.width = 7, fig.height = 5---------------------------------- ent <- asc_entities(traits, k_max = 10, B = 50, seed = 1) summary(ent) plot(ent) ## ----entities_use------------------------------------------------------------- res_e <- asc_null(res, n_perm = 199, seed = 1, entities = ent) res_e$null_models[res_e$null_models$Layer == "Position", c("Contrast", "Test", "SES", "P_upper")] asc_transitions(res, entities = ent)$Logged$entities ## ----pairwise----------------------------------------------------------------- pw <- asc_pairwise(traits, birds_sim$landscape) pw <- asc_null(pw, n_perm = 199, seed = 1) summary(pw) plot(pw, contrast = "Primary_vs_Farmland", type = "both", n_sp = 5) ## ----baseline----------------------------------------------------------------- summary(asc_baseline(traits, birds_sim$landscape))