## ----include = FALSE----------------------------------------------------------
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

## ----setup--------------------------------------------------------------------
library(pacha)
# devtools::load_all("C:/Users/PC/My Drive/R Packages/pacha")

## -----------------------------------------------------------------------------
pacha_configure()

## -----------------------------------------------------------------------------
pacha_configure(source = "api", dataset = "313479", language = "es")

## -----------------------------------------------------------------------------
species <- "Bidens andicola"
pacha_sc_full_name(species)

## -----------------------------------------------------------------------------
# Common / vernacular names, grouped by language
common_names_pacha(species)

# Establishment status: native, introduced, cultivated, naturalized...
establishment_pacha(species, language = "en")

# Conservation status, typically an IUCN-style category
threat_status_pacha(species, refresh = TRUE)

# Related URLs: the source record, the canonical taxon page, IPNI, etc.
indexation_urls_pacha(species)

## -----------------------------------------------------------------------------
sustainable_uses_pacha(species)
sustainable_uses_pacha(species, use = "medicinal")

## -----------------------------------------------------------------------------
is_listed_pacha(species)
is_listed_pacha(species, detailed = TRUE)

## -----------------------------------------------------------------------------
reference_pacha()

## -----------------------------------------------------------------------------
# Just one species, from both sources
pacha_clear_cache("Bidens andicola")

# Everything, including the cached local ColDP tables
pacha_clear_cache()

## ----eval=FALSE---------------------------------------------------------------
# my_fetcher <- function(species, config) {
#   list(
#     common_names = list(es = c("nombre comun")),
#     sustainable_uses = list(Medicinal = c("uso medicinal registrado")),
#     indexation_urls = c(source = "https://example.org/taxon/123"),
#     establishment = "native",
#     threat_status = "LC",
#     transport_error = FALSE,
#     transport_messages = character()
#   )
# }
# 
# pacha_configure(fetcher = my_fetcher)
# 

## ----eval = FALSE-------------------------------------------------------------
# pacha_report(c("Bidens andicola", "Bomarea multiflora"), language = "en")

## -----------------------------------------------------------------------------
pacha_report(c(
  "Alternanthera porrigens", # bledo
  "Amaranthus asplundii",    # colada morada
  "Amaranthus hybridus",     # planta calle Lata
  "Guilleminea densa"
))

