This vignette demonstrates the BetaStability package using
linearPred with the Ponds dataset from the rioja
package.
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")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")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_riojaprint(sessionInfo())
#> R version 4.6.0 (2026-04-24)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.4 LTS
#>
#> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
#>
#> locale:
#> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
#> [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
#> [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
#> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
#> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
#>
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#>
#> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base
#>
#> other attached packages:
#> [1] ggplot2_4.0.3 vegan_2.7-5 permute_0.9-10
#> [4] betaStability_0.0.4 rmarkdown_2.31
#>
#> loaded via a namespace (and not attached):
#> [1] sass_0.4.10 shape_1.4.6.1 stringi_1.8.7
#> [4] lattice_0.22-9 usedist_0.4.0 digest_0.6.39
#> [7] magrittr_2.0.5 rioja_1.0-7 evaluate_1.0.5
#> [10] grid_4.6.0 RColorBrewer_1.1-3 BBmisc_1.13.1
#> [13] iterators_1.0.14 fastmap_1.2.0 xgboost_3.2.1.1
#> [16] glmnet_5.0 Matrix_1.7-5 foreach_1.5.2
#> [19] doParallel_1.0.17 plyr_1.8.9 jsonlite_2.0.0
#> [22] backports_1.5.1 survival_3.8-6 mgcv_1.9-4
#> [25] scales_1.4.0 pbapply_1.7-4 codetools_0.2-20
#> [28] jquerylib_0.1.4 cli_3.6.6 rlang_1.2.0
#> [31] splines_4.6.0 withr_3.0.2 cachem_1.1.0
#> [34] yaml_2.3.12 otel_0.2.0 tools_4.6.0
#> [37] parallel_4.6.0 reshape2_1.4.5 checkmate_2.3.4
#> [40] gdm_1.6.0-7 buildtools_1.0.0 vctrs_0.7.3
#> [43] R6_2.6.1 lifecycle_1.0.5 randomForest_4.7-1.2
#> [46] stringr_1.6.0 MASS_7.3-65 cluster_2.1.8.2
#> [49] bslib_0.11.0 gtable_0.3.6 data.table_1.18.4
#> [52] glue_1.8.1 Rcpp_1.1.1-1.1 xfun_0.58
#> [55] sys_3.4.3 knitr_1.51 farver_2.1.2
#> [58] nlme_3.1-169 htmltools_0.5.9 labeling_0.4.3
#> [61] maketools_1.3.2 compiler_4.6.0 S7_0.2.2