knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(TDA) library(tidyverse) library(lubridate)
Load in data from package and select sites with at least 8 years of data
data(all_bibi_data) sites_with_8plus_years<-all_bibi_data %>% group_by(Sites) %>% summarise(n=length(Year)) %>% filter(n>=8) %>% pull(Sites)
Set up a threshold for the trend magnitude of ecological significance
threshold=-1*0.5
Complete trend and power analysis
power_out<-all_bibi_data %>% filter(Sites %in% sites_with_8plus_years) %>% #filter(Sites %in% sites_with_8plus_years[1:5]) %>% select(Sites,Year,BIBI=`Overall Score`) %>% with(.,TDA_Power(value=BIBI,year=Year,site=Sites,trend.magnitude.threshold = threshold))
Let's peak at that table
knitr::kable( head(power_out) )
power_out %>% mutate(Result=factor(Result,levels=c('Decreasing','Inadequate Data','Maintaining','Increasing'), labels=c('Degrading','Inadequate Data','Maintaining','Improving'))) %>% ggplot()+ geom_bar(aes(x=1,fill=Result),col='black',position = position_stack())+ theme_bw()+ theme(axis.text.x = element_blank(), axis.title.x = element_blank(), axis.ticks.x=element_blank())
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.