R/remove_species_without_trait.R

Defines functions remove_species_without_trait

#' Remove species with missing trait data
#'
#' @param trait_mat a matrix of trait values with species as rows and traits as
#'                  columns
#'
#' @importFrom stats complete.cases
#' @noRd
remove_species_without_trait <- function(trait_mat) {

  complete_traits <- complete.cases(trait_mat)

  if (sum(complete_traits) != nrow(trait_mat)) {
    message("Removed ", sum(!complete_traits), " species with missing trait(s)")
  }

  trait_mat[complete_traits,, drop = FALSE]
}

Try the fundiversity package in your browser

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

fundiversity documentation built on Nov. 21, 2022, 5:07 p.m.