Skip to contents

This function calculates the phylogenetic diversity (PD) for a given dataset and phylogenetic tree.

Usage

calc_pd(Fin, Tree)

Arguments

Fin

A data frame or data table containing species presence data. The data should include columns for species, cell, and Landuse.

Tree

A phylogenetic tree object, typically generated by the V.PhyloMaker::phylo.maker function. The tree must contain a component named scenario.3 with the tip labels.

Value

A data table containing the calculated phylogenetic diversity (PD) for each cell, along with the associated cell and Landuse.

Examples

if (FALSE) { # \dontrun{
  # Example usage:
  Fin <- data.table(
    cell = c(1, 1, 2, 2),
    species = c("species_a", "species_b", "species_a", "species_c"),
    Landuse = c("forest", "forest", "grassland", "grassland")
  )

  # Assume this generates a valid tree object
  Tree <- V.PhyloMaker::phylo.maker(...)

  # Calculate phylogenetic diversity
  pd_results <- calc_pd(Fin, Tree)
  print(pd_results)
} # }