Skip to contents

This function calculates the average scarcity index (Si) for each species across sites using relative abundance data and the funrar package's scarcity_stack() function.

Usage

compute_mean_si(
  data,
  species_col = "species",
  site_col = "site",
  abundance_col = "abundance"
)

Arguments

data

A data frame containing species, site, and abundance information.

species_col

Name of the column in data indicating species identity. Defaults to "species".

site_col

Name of the column in data indicating site identity. Defaults to "site".

abundance_col

Name of the column in data containing species abundance per site. Defaults to "abundance".

Value

A data frame with species and their corresponding mean Si values.

Details

It first computes relative abundances within each site, applies scarcity_stack() from the funrar package, and then averages the Si values for each species.

This function uses funrar::scarcity_stack() to compute the scarcity index (Si) per species per site based on relative abundance, and then returns the average Si per species.

Note

This function requires the funrar package. If you use this function in published work, please cite the funrar package using: citation("funrar").

Examples


df <- data.frame(
  species = c("sp1", "sp2", "sp1", "sp3", "sp2", "sp3"),
  site = c("A", "A", "B", "B", "C", "C"),
  abundance = c(10, 5, 3, 8, 2, 7)
)
compute_mean_si(df)
#> # A tibble: 3 × 2
#>   species    Si
#>   <chr>   <dbl>
#> 1 sp1     0.541
#> 2 sp2     0.682
#> 3 sp3     0.353