knitr::opts_chunk$set(echo = TRUE) library(drake) library(dplyr) library(ggplot2)
all_dat <- portalr::plant_abundance(level = "Treatment", type = "Annuals", plots = "All", unknowns = F, correct_sp = T, shape = "flat", min_quads = 16) %>% dplyr::filter(treatment == "control") %>% dplyr::select(year, species, abundance, season) %>% dplyr::rename(abund = abundance) %>% dplyr::group_by(year, season) %>% dplyr::arrange(abund) %>% dplyr::mutate(rank = dplyr::row_number()) %>% dplyr::ungroup() %>% dplyr::select(-species) %>% dplyr::mutate(sim = -99, source = "observed") all_dat <- all_dat %>% group_by(year, season) %>% summarize(nspp = max(rank), nind = sum(abund)) %>% ungroup() statevar_plot <- ggplot(data = all_dat, aes(x = nspp, y = nind, label = year, color = season)) + geom_label() + theme_bw() + scale_color_viridis_d(end = .6) statevar_plot
nind_hist <- ggplot(data = all_dat, aes(x = nind)) + geom_density() + theme_bw() nind_hist nspp_hist <- ggplot(data = all_dat, aes(x = nspp)) + geom_density() + theme_bw() nspp_hist
small_years <- all_dat %>% filter(nspp <= 40, nind <= 15000) %>% group_by(year) %>% summarize(nb_seasons = n()) %>% ungroup() %>% filter(nb_seasons == 2) small_years_dat <- all_dat %>% filter(year %in% small_years$year) small_statevar_plot <- ggplot(data = small_years_dat, aes(x = nspp, y = nind, label = year, color = season)) + geom_label() + theme_bw() + scale_color_viridis_d(end = .6) small_statevar_plot small_years_dat
```
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.