rel_abundance: Calculate the Relative Abundance of Nematodes

View source: R/ecological_indices.R

rel_abundanceR Documentation

Calculate the Relative Abundance of Nematodes

Description

This function calculates the relative abundance of nematodes for each sample. The relative abundance is defined as the proportion of each nematode's count to the total count of all nematodes in a sample.

Usage

rel_abundance(data, ...)

## S3 method for class 'data.frame'
rel_abundance(data, ...)

## S3 method for class 'matrix'
rel_abundance(data, ...)

## Default S3 method:
rel_abundance(data, ...)

Arguments

data

data.frame or matrix. The nematode abundance table where rows represent samples and columns represent nematodes. Each element indicates the count of a specific nematode in the corresponding sample.

...

Additional arguments (currently unused).

Value

A data.frame or matrix (matching the input type) containing the relative abundance of each nematode in each sample.

Examples

# Example with a data frame
df <- data.frame(
  Species1 = c(10, NA, 15),
  Species2 = c(5, 10, NA),
  Species3 = c(8, 12, 10),
  row.names = c("A", "B", "C")
)
rel_abundance(df)

# Example with a matrix
mat <- matrix(c(10, NA, 15, 5, 10, NA, 8, 12, 10), nrow = 3, byrow = TRUE)
colnames(mat) <- c("Species1", "Species2", "Species3")
row.names(mat) <- c("A", "B", "C")
rel_abundance(mat)


Nematode documentation built on Aug. 21, 2025, 5:58 p.m.