#' Convert abundance data to incidence data
#'
#' Take an abundance dataset and remove abundance information, leaving
#' only presence (1) and incidence (0) data.
#'
#' @param dataset A data frame containing abundance or incidence data
#' @return The subsampled dataset as a tibble
#'
#' @export
#'
#' @examples
#' library(iNEXT)
#' data(bird)
#' to_incidence(bird)
#'
to_incidence <- function(dataset)
{
incidence <- lapply(as.list(dataset), to01)
incidence <- as.data.frame(incidence)
rownames(incidence) <- rownames(dataset)
return(tibble::as_data_frame(incidence))
}
to01 <- function(col)
{
present <- col > 0
incidence <- present * 1
return(incidence)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.