#' @title Margalef index
#'
#' @description Computes Margalef's index
#'
#' @param x Vector of dimension S (number of species) with the number of individuals observed in each species. NA values are allowed. 0 values are converted to NA.
#'
#' @return Margalef index.
#'
#' @references
#' "Quantifying Diversity through Entropy Decomposition: Insights into Hominin Occupation and Carcass Processing at Qesem cave"
#'
#' @examples
#' data(Qesem_s)
#' margalef(Qesem_s$HU)
#'
#' @export
margalef  <- function(x){
  x <- check_x(x)
  return((length(x)-1)/log(sum(x)))
}
