iucnn_prepare_labels: Format IUCN Red List categories for IUCNN

View source: R/iucnn_prepare_labels.R

iucnn_prepare_labelsR Documentation

Format IUCN Red List categories for IUCNN

Description

Converting IUCN category labels into numeric categories required by iucnn_train_model.

Usage

iucnn_prepare_labels(
  x,
  y,
  species = "species",
  labels = "labels",
  accepted_labels = c("LC", "NT", "VU", "EN", "CR"),
  level = "detail",
  threatened = c("CR", "EN", "VU")
)

Arguments

x

a data.frame or a list. If a data.frame, two columns with the species names and IUCN categories respectively. The column names are defined by the species and labels arguments. If a list, expecting the format as returned by rredlist::rl_search.

y

object of class iucnn-features or iucnn_cnn_features. Ensures that the species in the return value are in the same order as in y.

species

a character string. The name of the column with the species names in x.

labels

a character string. The name of the column with the labels (assessment categories) in x.

accepted_labels

a character string. The labels to be converted in to numeric values. Entries with labels not mentioned (e.g. "DD") will be removed. The numeric labels returned by the function will correspond to the order in this argument. For instance with default settings, LC -> 0, CR -> 4.

level

a character string. The level of output level detail. If "detail" full IUCN categories, if "broad" then 0 = Not threatened, and 1 = Threatened.

threatened

a character string. Only if level=="broad", Which labels to consider threatened.

Value

a data.frame with species names and numeric labels

Note

See vignette("Approximate_IUCN_Red_List_assessments_with_IUCNN") for a tutorial on how to run IUCNN.

Examples

## Not run: 
dat <- data.frame(species = c("A", "B"),
                  decimallongitude = runif(200, 10, 15),
                  decimallatitude = runif(200, -5, 5))

labs <- data.frame(species = c("A", "B"),
                   labels = c("CR", "LC"))

features <- iucnn_prepare_features(dat,
                                   type = "geographic")

iucnn_prepare_labels(x = labs,
                     y = features)

## End(Not run)

azizka/IUCNN documentation built on March 29, 2024, 9:38 a.m.