BetaStability with rioja datasets

Yu Gao(gaoyu19920914@gmail.com)

2026-10-09

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.6.1 (2026-06-24 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.3       vegan_2.7-6         permute_0.9-10     
#> [4] betaStability_0.1.0
#> 
#> loaded via a namespace (and not attached):
#>  [1] gtable_0.3.6         shape_1.4.6.1        xfun_0.61           
#>  [4] bslib_0.12.0         raster_3.6-32        BBmisc_1.13.1       
#>  [7] lattice_0.23-1       vctrs_0.7.3          tools_4.6.1         
#> [10] generics_0.1.4       parallel_4.6.1       tibble_3.3.1        
#> [13] cluster_2.1.8.3      pkgconfig_2.0.3      Matrix_1.7-6        
#> [16] data.table_1.18.6.1  checkmate_2.3.4      RColorBrewer_1.1-3  
#> [19] S7_0.2.2             lifecycle_1.0.5      compiler_4.6.1      
#> [22] farver_2.1.2         stringr_1.6.0        terra_1.9-50        
#> [25] codetools_0.2-20     htmltools_0.5.9      sass_0.4.10         
#> [28] yaml_2.3.12          glmnet_5.0           pillar_1.11.1       
#> [31] jquerylib_0.1.4      MASS_7.3-66          rioja_1.0-7         
#> [34] gdm_1.6.0-7          cachem_1.1.0         elevatr_0.99.1      
#> [37] iterators_1.0.14     foreach_1.5.2        nlme_3.1-171        
#> [40] tidyselect_1.2.1     digest_0.6.39        stringi_1.8.9       
#> [43] dplyr_1.2.1          reshape2_1.4.5       purrr_1.2.2         
#> [46] labeling_0.4.3       splines_4.6.1        fastmap_1.2.0       
#> [49] grid_4.6.1           cli_3.6.6            magrittr_2.0.5      
#> [52] randomForest_4.7-1.2 survival_3.8-12      withr_3.0.3         
#> [55] scales_1.4.0         backports_1.5.1      xgboost_3.2.1.1     
#> [58] sp_2.2-3             usedist_0.4.0        rmarkdown_2.32      
#> [61] otel_0.2.0           progressr_1.0.0      pbapply_1.7-5       
#> [64] evaluate_1.0.5       knitr_1.52           doParallel_1.0.17   
#> [67] mgcv_1.9-4           rlang_1.3.0          Rcpp_1.1.2          
#> [70] glue_1.8.1           rstudioapi_0.19.0    jsonlite_2.0.0      
#> [73] R6_2.6.1             plyr_1.8.9