BetaStability with rioja datasets

Yu Gao(gaoyu19920914@gmail.com)

2026-06-01

BetaStability with rioja datasets

This vignette demonstrates the BetaStability package using linearPred with the Ponds dataset from the rioja package.

Installation

First, install the package from GitHub:

# Install from GitHub
# install.packages("devtools")
# devtools::install_github("gaoyu19920914/betaStability")

# OR install from BioConductor (in the future when it's available)
# if (!requireNamespace("BiocManager", quietly = TRUE))
#     install.packages("BiocManager")
# BiocManager::install("betaStability")

Loading Required Packages

Load the BetaStability package and the rioja package for test data:

library(betaStability)
library(vegan)
library(ggplot2)
# Check if rioja is available and install it to load dataset
if (!requireNamespace("rioja", quietly = TRUE)) install.packages("rioja")
data("Ponds", package = "rioja")

rioja dataset with linearPred

comtable <- Ponds$spec
envmeta <- Ponds$env[, 6:19]

# Calculate stability with linearPred
stability_rioja_linear <- betaStability(
    comtable = comtable,
    envmeta = envmeta,
    method = "linearPred"
)

# Inspect the result
head(stability_rioja_linear)
#>    stability_Linear
#> 4       -0.03592404
#> 7        0.11670026
#> 31       0.06042562
#> 34       0.04890066
#> 37       0.03335611
#> 42      -0.08761045
p_rioja <- plotStability(stability_rioja_linear, sitenames = Ponds$env$Name)
p_rioja

print(sessionInfo())
#> R version 4.5.3 (2026-03-11 ucrt)
#> Platform: x86_64-w64-mingw32/x64
#> Running under: Windows 11 x64 (build 26200)
#> 
#> Matrix products: default
#>   LAPACK version 3.12.1
#> 
#> locale:
#> [1] LC_COLLATE=C                          
#> [2] LC_CTYPE=English_United States.utf8   
#> [3] LC_MONETARY=English_United States.utf8
#> [4] LC_NUMERIC=C                          
#> [5] LC_TIME=English_United States.utf8    
#> 
#> time zone: Asia/Shanghai
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggplot2_4.0.2       vegan_2.7-3         permute_0.9-10     
#> [4] betaStability_0.0.4
#> 
#> loaded via a namespace (and not attached):
#>  [1] sass_0.4.10          generics_0.1.4       shape_1.4.6.1       
#>  [4] stringi_1.8.7        lattice_0.22-9       usedist_0.4.0       
#>  [7] digest_0.6.39        magrittr_2.0.4       rioja_1.0-7         
#> [10] evaluate_1.0.5       grid_4.5.3           RColorBrewer_1.1-3  
#> [13] BBmisc_1.13.1        iterators_1.0.14     fastmap_1.2.0       
#> [16] xgboost_3.2.1.1      glmnet_4.1-10        Matrix_1.7-5        
#> [19] foreach_1.5.2        doParallel_1.0.17    plyr_1.8.9          
#> [22] jsonlite_2.0.0       backports_1.5.0      survival_3.8-6      
#> [25] mgcv_1.9-4           scales_1.4.0         pbapply_1.7-4       
#> [28] codetools_0.2-20     jquerylib_0.1.4      cli_3.6.5           
#> [31] rlang_1.1.7          splines_4.5.3        withr_3.0.2         
#> [34] cachem_1.1.0         yaml_2.3.12          otel_0.2.0          
#> [37] tools_4.5.3          parallel_4.5.3       reshape2_1.4.5      
#> [40] checkmate_2.3.4      dplyr_1.2.0          gdm_1.6.0-7         
#> [43] vctrs_0.7.2          R6_2.6.1             lifecycle_1.0.5     
#> [46] randomForest_4.7-1.2 stringr_1.6.0        MASS_7.3-65         
#> [49] cluster_2.1.8.2      pkgconfig_2.0.3      pillar_1.11.1       
#> [52] bslib_0.10.0         gtable_0.3.6         data.table_1.18.2.1 
#> [55] glue_1.8.0           Rcpp_1.1.1           xfun_0.57           
#> [58] tibble_3.3.1         tidyselect_1.2.1     rstudioapi_0.18.0   
#> [61] knitr_1.51           farver_2.1.2         nlme_3.1-169        
#> [64] htmltools_0.5.9      labeling_0.4.3       rmarkdown_2.31      
#> [67] compiler_4.5.3       S7_0.2.1