tests/testthat/test-compute_envfit_vectors.R

library(testthat)

test_that("compute_envfit_vectors returns vectors filtered by significance", {
  library(vegan)

  data(dune)
  data(dune.env)
  rda_mod <- rda(dune ~ A1 + Moisture, data = dune.env)

  all_vecs <- compute_envfit_vectors(rda_mod, dune.env, p_thresh = 0.05, show.significant = FALSE)
  sig_vecs <- compute_envfit_vectors(rda_mod, dune.env, p_thresh = 0.05, show.significant = TRUE)

  expect_true(nrow(all_vecs) >= nrow(sig_vecs))
  expect_true(all(sig_vecs$pval <= 0.05))
})

Try the barrel package in your browser

Any scripts or data that you put into this service are public.

barrel documentation built on Nov. 5, 2025, 7:40 p.m.