tests/testthat/test-diversity.R

test_that("shdi matches vegan's results", {
  library(vegan)
  data(dune)
  df <- table2df(dune)
  res <- 
    shdi(df) %>%
    dplyr::mutate(stand = as.numeric(stand)) %>%
    dplyr::arrange(stand)
  expect_equal(res$s, unname(specnumber(dune)))
  expect_equal(res$h, unname(diversity(dune, index="shannon")))
  expect_equal(res$d, unname(diversity(dune, index="simpson")))
  expect_equal(res$i, unname(diversity(dune, index="invsimpson")))
})

Try the ecan package in your browser

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

ecan documentation built on July 9, 2023, 5:13 p.m.