### Example: Get all comprehensive groups Source: https://docs.ropensci.org/rredlist/reference/rl_comp_groups.html This example demonstrates how to call `rl_comp_groups` without any arguments to retrieve a list of all available comprehensive groups. ```R # Get list of all comprehensive groups rl_comp_groups() ``` -------------------------------- ### Example: Get assessment summary for a specific group Source: https://docs.ropensci.org/rredlist/reference/rl_comp_groups.html This example shows how to fetch the assessment summary for a specific comprehensive group by providing its name, such as 'seasnakes'. ```R # Get assessment summary for sea snakes rl_comp_groups('seasnakes') ``` -------------------------------- ### Example: Get Fungi Kingdom Assessment Summary Source: https://docs.ropensci.org/rredlist/reference/rl_kingdom.html Demonstrates how to call `rl_kingdom` to get assessment data for the 'Fungi' kingdom and check the number of assessments returned. ```R if (FALSE) { # \dontrun{ # Get assessment summary for kingdom ex1 <- rl_kingdom(kingdom = "Fungi") nrow(ex1$assessments) } # } ``` -------------------------------- ### Get All Conservation Actions Source: https://docs.ropensci.org/rredlist/reference/rl_actions.html This example demonstrates how to retrieve a list of all available conservation actions by calling `rl_actions()` without any arguments. This is useful for understanding the available codes. ```R # Get list of all conservation actions rl_actions() ``` -------------------------------- ### Get list of all systems Source: https://docs.ropensci.org/rredlist/reference/rl_systems.html Retrieves a list of all available ecological systems from the IUCN Red List API. This is a basic usage example. ```r rl_systems() ``` -------------------------------- ### Get Assessment Details Example Source: https://docs.ropensci.org/rredlist/reference/rl_assessment.html Demonstrates how to retrieve and access specific details (red list category code and systems) for a given assessment ID. ```R if (FALSE) { # \dontrun{ # Get assessment details for Fratercula arctica ex1 <- rl_assessment(id = 166290968) ex1$red_list_category$code ex1$systems } # } ``` -------------------------------- ### Example: Sign up for an IUCN API Key Source: https://docs.ropensci.org/rredlist/reference/rl_use_iucn.html Demonstrates how to initiate the process of signing up for an IUCN Red List API key. This example is typically run interactively and requires user input on the IUCN website. ```r if (FALSE) { # \dontrun{ # Sign up for an API key rl_use_iucn() } # } ``` -------------------------------- ### Clone Repository Example Source: https://docs.ropensci.org/rredlist/CONTRIBUTING.html Clone your forked version of the rredlist repository to your local machine. ```bash git clone https://github.com//rredlist.git ``` -------------------------------- ### Get count of species with assessments Source: https://docs.ropensci.org/rredlist/reference/rl_sp_count.html This example shows how to get the count of species that have assessments in the IUCN Red List. It requires an active internet connection and potentially an IUCN API token if not already configured. ```r if (FALSE) { # \dontrun{ # Get count of species with assessments rl_sp_count() } # } ``` -------------------------------- ### Load rredlist and microbenchmark Libraries Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Load the necessary libraries for benchmarking. Ensure these libraries are installed before running. ```r library(rredlist) library(microbenchmark) ``` -------------------------------- ### Get Assessments with Specific Conservation Action Source: https://docs.ropensci.org/rredlist/reference/rl_actions.html This example shows how to query for species assessments that require a specific conservation action, using the code '3_2' for 'Species recovery'. This helps in identifying species that need targeted conservation efforts. ```R # Get assessments with Species recovery conservation action needed rl_actions("3_2") ``` -------------------------------- ### Install rredlist from CRAN Source: https://docs.ropensci.org/rredlist/index.html Install the stable version of the rredlist package from CRAN. ```r install.packages("rredlist") ``` -------------------------------- ### Install rredlist Development Version Source: https://docs.ropensci.org/rredlist/index.html Install the latest development version of the rredlist package from GitHub or an R-universe repository. ```r remotes::install_github("ropensci/rredlist") ``` ```r install.packages("rredlist", repos = "https://ropensci.r-universe.dev/") ``` -------------------------------- ### Get Stable Population Trend Assessments Source: https://docs.ropensci.org/rredlist/reference/rl_pop_trends.html This example demonstrates how to filter and retrieve only the population trend assessments that are marked as 'stable'. The code '2' is used as the filter. ```r rl_pop_trends("2") ``` -------------------------------- ### Add Upstream Remote Example Source: https://docs.ropensci.org/rredlist/CONTRIBUTING.html Add the official rredlist repository as an upstream remote to track changes. ```bash git remote add upstream https://github.com/ropensci/rredlist.git ``` -------------------------------- ### Set up IUCN API Key Source: https://docs.ropensci.org/rredlist/index.html Use the helper function to get and store your IUCN API key for package authentication. Ensure your key is kept private. ```r rredlist::rl_use_iucn() ``` -------------------------------- ### Get List of All Habitats Source: https://docs.ropensci.org/rredlist/reference/rl_habitats.html Call `rl_habitats()` without any arguments to retrieve a list of all available habitats. ```r rl_habitats() ``` -------------------------------- ### Get all growth forms Source: https://docs.ropensci.org/rredlist/reference/rl_growth_forms.html Retrieves a list of all available growth forms. This is useful for understanding the available categories. ```r if (FALSE) { # \dontrun{ # Get list of all growth forms rl_growth_forms() # Get assessment summary for lichens rl_growth_forms("LC") } # } ``` -------------------------------- ### Get assessment summary for a specific scope Source: https://docs.ropensci.org/rredlist/reference/rl_scopes.html Use the 'code' argument to specify a particular scope and retrieve its assessment summary. This example uses the code for the Gulf of Mexico. ```r rl_scopes(code = "45433062") ``` -------------------------------- ### Get Assessments for a Specific Habitat Source: https://docs.ropensci.org/rredlist/reference/rl_habitats.html Use the `code` argument to specify a habitat code (e.g., "12" for Marine Intertidal) to get its assessments. ```r rl_habitats("12") ``` -------------------------------- ### Get assessment summary for an order Source: https://docs.ropensci.org/rredlist/reference/rl_order.html Retrieves the assessment summary for the specified order. Use this to get a list of all assessments for a given taxonomic order. ```r if (FALSE) { # \dontrun{ # Get assessment summary for order ex1 <- rl_order(order = "Apiales") nrow(ex1$assessments) } # } ``` -------------------------------- ### Get SIS Assessment Summary Source: https://docs.ropensci.org/rredlist/reference/rl_sis.html Fetches the assessment summary for a given species ID from the IUCN SIS. The output is parsed into a list by default. This example demonstrates how to retrieve the data and check the number of assessments. ```r if (FALSE) { # \dontrun{ # Get assessment summary for species ex1 <- rl_sis(id = 9404) nrow(ex1$assessments) } # } ``` -------------------------------- ### Helper to get and save IUCN API key Source: https://docs.ropensci.org/rredlist/reference/index.html Use `rl_use_iucn()` as a helper function to get and save your IUCN API key. ```r rl_use_iucn() ``` -------------------------------- ### Get the Red List version Source: https://docs.ropensci.org/rredlist/reference/index.html Use `rl_version()` to retrieve the current version of the Red List data. ```r rl_version() ``` -------------------------------- ### Benchmark: Get Species Count Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Compares the performance of rl_sp_count() and rl_sp_count_() for retrieving species counts. Both functions are tested 10 times. ```r microbenchmark( rl_sp_count(), rl_sp_count_(), times = 10 ) ``` -------------------------------- ### Install Older rredlist Version for API v3 Source: https://docs.ropensci.org/rredlist/articles/rredlist.html Install a specific older version (<= 0.7.1) of the rredlist package to use the now-defunct version 3 of the IUCN Red List API. This can be done from the CRAN archive or an r-universe repository. ```r # From CRAN archive remotes::install_version("rredlist", version = "0.7.1") # From r-universe remotes::install_version("rredlist", version = "0.7.1", repos = "https://ropensci.r-universe.dev/") ``` -------------------------------- ### Get all threats Source: https://docs.ropensci.org/rredlist/reference/rl_threats.html Call `rl_threats()` without any arguments to retrieve a list of all available threat codes. ```r rl_threats() ``` -------------------------------- ### Load Required R Packages Source: https://docs.ropensci.org/rredlist/articles/research_workflows.html Loads the rredlist, dplyr, ggplot2, and patchwork packages. Ensure these packages are installed before running. ```r library(rredlist) library(dplyr) library(ggplot2) library(patchwork) ``` -------------------------------- ### Get List of All Countries Source: https://docs.ropensci.org/rredlist/reference/rl_countries.html This snippet demonstrates how to retrieve a list of all countries for which Red List assessments are available. Ensure you have an internet connection. ```R if (FALSE) { # \dontrun{ # Get list of all countries rl_countries() } ``` -------------------------------- ### Get all stresses Source: https://docs.ropensci.org/rredlist/reference/rl_stresses.html To retrieve a list of all available stresses, call the `rl_stresses()` function without any arguments. ```r rl_stresses() ``` -------------------------------- ### Get assessment summary for a class Source: https://docs.ropensci.org/rredlist/reference/rl_class.html Retrieves the assessment summary for the 'Mammalia' class. The number of assessments is then printed. ```r if (FALSE) { # \dontrun{ # Get assessment summary for class ex1 <- rl_class(class = "Mammalia") nrow(ex1$assessments) } # } ``` -------------------------------- ### Get all use and trade assessments Source: https://docs.ropensci.org/rredlist/reference/rl_use_and_trade.html Fetches all available use and trade assessments. This function requires no arguments to retrieve the complete list. ```r rl_use_and_trade() ``` -------------------------------- ### Get a list of all FAO regions Source: https://docs.ropensci.org/rredlist/reference/rl_faos.html Demonstrates how to call `rl_faos()` without any arguments to retrieve a list of all available FAO regions. This is useful for identifying region codes. ```r # Get a list of all scopes rl_faos() ``` -------------------------------- ### Get IUCN Red List API Version Source: https://docs.ropensci.org/rredlist/reference/rl_api_version.html Fetches the current version of the IUCN Red List API. Requires an API key if not already set. ```r rl_api_version() ``` -------------------------------- ### Get All Red List Categories Source: https://docs.ropensci.org/rredlist/reference/rl_categories.html Fetches all available Red List categories when no specific code is provided. This is useful for exploring the available categories. ```R rl_categories() ``` -------------------------------- ### Retrieve all stress assessments with pagination handled internally Source: https://docs.ropensci.org/rredlist/reference/rl_stresses.html This example demonstrates how to fetch all stress assessments. The `all = TRUE` argument ensures that all pages of results are retrieved and combined. The `quiet = FALSE` argument (default) will show progress for multi-page downloads. ```r rl_stresses(all = TRUE, quiet = FALSE) ``` -------------------------------- ### Get assessment summary for a specific stress Source: https://docs.ropensci.org/rredlist/reference/rl_stresses.html To get the assessment summary for a particular stress, provide its corresponding code to the `rl_stresses()` function. For example, to retrieve information on 'Ecosystem degradation', use the code '1_2'. ```r rl_stresses("1_2") ``` -------------------------------- ### Get assessment summary for a specific threat Source: https://docs.ropensci.org/rredlist/reference/rl_threats.html To get assessment summaries for a particular threat, provide its corresponding code. For example, to find assessments related to intentional hunting and trapping, use the code "5_1_1". Note that sub-threats require separate requests. ```r rl_threats("5_1_1") ``` -------------------------------- ### Get assessment summary for phylum Source: https://docs.ropensci.org/rredlist/reference/rl_phylum.html Retrieves conservation assessment summaries for a specified phylum. Ensure you have the 'rredlist' package installed and potentially an IUCN API key configured if required by the API. ```R if (FALSE) { # \dontrun{ # Get assessment summary for phylum ex1 <- rl_phylum(phylum = "Annelida`") nrow(ex1$assessments) } # } ``` -------------------------------- ### Benchmark: Taxonomic Lookup with Query (~40 Pages) Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Compares the performance of rl_family() and rl_family_() when querying for a family with approximately 40 pages of results ('Tyrannidae'). The 'quiet = TRUE' argument is used, and functions are tested 10 times. ```r microbenchmark( rl_family("Tyrannidae", quiet = TRUE), rl_family_("Tyrannidae", quiet = TRUE), times = 10 ) ``` -------------------------------- ### Benchmark: Taxonomic Lookup with Query (~10 Pages) Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Compares the performance of rl_family() and rl_family_() when querying for a family with approximately 10 pages of results ('Corvidae'). The 'quiet = TRUE' argument is used, and functions are tested 10 times. ```r microbenchmark( rl_family("Corvidae", quiet = TRUE), rl_family_("Corvidae", quiet = TRUE), times = 10 ) ``` -------------------------------- ### Get assessment details for multiple assessments Source: https://docs.ropensci.org/rredlist/reference/rl_assessment_list.html Use `rl_assessment_list` to retrieve details for multiple assessments by providing a vector of their unique identifiers. This example demonstrates fetching data for two specific assessment IDs. ```r if (FALSE) { # \dontrun{ # Get assessment details for multiple assessments ex1 <- rl_assessment_list(ids = c(166290968, 136250858)) } # } ``` -------------------------------- ### Benchmark: Taxonomic Lookup with Defaults Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Compares the performance of rl_family() and rl_family_() for a default taxonomic lookup. Both functions are tested 10 times. ```r microbenchmark( rl_family(), rl_family_(), times = 10 ) ``` -------------------------------- ### Get assessment summary for medicinal use and trade Source: https://docs.ropensci.org/rredlist/reference/rl_use_and_trade.html Retrieves the assessment summary for a specific use and trade, identified by its code. In this example, code '3' is used to fetch details related to medicinal use and trade. ```r rl_use_and_trade("3") ``` -------------------------------- ### Benchmark: Taxonomic Lookup with Query (~900 Pages) Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Compares the performance of rl_class() and rl_class_() when querying for a class with approximately 900 pages of results ('Aves'). The 'quiet = TRUE' argument is used, and functions are tested 10 times. ```r microbenchmark( rl_class("Aves", quiet = TRUE), rl_class_("Aves", quiet = TRUE), times = 10 ) ``` -------------------------------- ### Benchmark: Taxonomic Lookup with Query (One Page) Source: https://docs.ropensci.org/rredlist/articles/benchmarks.html Compares the performance of rl_family() and rl_family_() when querying for a specific family ('Rheidae'). Both functions are tested 10 times. ```r microbenchmark( rl_family("Rheidae"), rl_family_("Rheidae"), times = 10 ) ``` -------------------------------- ### Summarize and Calculate Habitat Proportions Source: https://docs.ropensci.org/rredlist/articles/research_workflows.html Summarizes habitat data by removing duplicates, counting species per habitat for each clade, and calculating the proportion of species in each habitat. This allows for direct comparison between clades. ```r gymno_counts <- gymno_habitats %>% select(sis_id, clade, code_major, habitat_major) %>% unique() %>% group_by(clade) %>% count(code_major, habitat_major, name = "cnt") %>% mutate(prop = cnt/length( unique(subset(gymno_habitats, clade == cur_group()$clade)$sis_id) )) ``` -------------------------------- ### Get Extinct Taxa Assessment Summary Source: https://docs.ropensci.org/rredlist/reference/rl_extinct.html Fetches an assessment summary for extinct taxa. The `rl_extinct` function returns a parsed list by default. Use `rl_extinct_` to get raw JSON. ```r if (FALSE) { # \dontrun{ ex1 <- rl_extinct() nrow(ex1$assessments) } # } ``` -------------------------------- ### Download Assessments with Helper Function Source: https://docs.ropensci.org/rredlist/articles/research_workflows.html Utilizes the `rl_assessment_list()` helper function to download multiple assessment records, which automatically includes recommended delays between queries to avoid timeouts. ```r assessment_list <- rl_assessment_list(assessment_ids) ``` -------------------------------- ### Get species latest assessment Source: https://docs.ropensci.org/rredlist/reference/index.html Use `rl_species_latest()` to retrieve the latest assessment for a species. ```r rl_species_latest() ``` -------------------------------- ### Example: Plotting with IUCN Fill Scale Source: https://docs.ropensci.org/rredlist/reference/scale_iucn.html Demonstrates how to use `scale_fill_iucn` to color points in a ggplot2 scatter plot based on IUCN Red List categories. Ensure the `ggplot2` library is loaded. ```r library(ggplot2) categories <- c("NE", "DD", "LC", "NT", "VU", "EN", "CR", "RE", "EW", "EX") df <- data.frame( x = runif(1000, 0, 10), y = runif(1000, 0, 10), color = sample(categories, 1000, TRUE), shape = 21 ) ggplot(df) + geom_point(aes(x = x, y = y, fill = color), shape = 21) + scale_fill_iucn(name = "IUCN Category") + theme_classic() ``` -------------------------------- ### Query assessments by habitats and systems Source: https://docs.ropensci.org/rredlist/reference/index.html Use `rl_habitats()` and `rl_systems()` to query assessments based on habitats and ecological systems. Variants with an underscore (e.g., `rl_habitats_()`) are also available. ```r rl_habitats() rl_habitats_() rl_systems() rl_systems_() ``` -------------------------------- ### Fetch and Merge Upstream Changes Source: https://docs.ropensci.org/rredlist/CONTRIBUTING.html Fetch and merge the latest changes from the upstream repository before making your own modifications. ```bash git fetch upstream # or git pull upstream ``` -------------------------------- ### Get details for one or more assessments Source: https://docs.ropensci.org/rredlist/reference/index.html Retrieve specific assessment details or a list of assessments from the Red List. ```APIDOC ## rl_assessment() / rl_assessment_() ### Description Retrieve details for one or more assessments. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_assessment_list() ### Description Retrieve a list of assessments. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_species_latest() ### Description Retrieve the latest assessment for a species. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_sis_latest() ### Description Retrieve the latest assessment using SIS ID. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_assessment_extract() ### Description Extract a specific element from an assessment. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ``` -------------------------------- ### Visualization tools Source: https://docs.ropensci.org/rredlist/reference/index.html Color scales for visualizing IUCN Red List data. ```APIDOC ## scale_color_iucn() / scale_fill_iucn() / scale_discrete_iucn() ### Description IUCN Red List color scales for visualizations. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ``` -------------------------------- ### Get Family Assessment Summary Source: https://docs.ropensci.org/rredlist/reference/rl_family.html Retrieves the assessment summary for the 'Hominidae' family. The number of assessments is then printed. ```R if (FALSE) { # \dontrun{ # Get assessment summary for family ex1 <- rl_family(family = "Hominidae") nrow(ex1$assessments) } # } ``` -------------------------------- ### Get a list of all scopes Source: https://docs.ropensci.org/rredlist/reference/rl_scopes.html Call rl_scopes without any arguments to retrieve a list of all available geographical assessment scopes. ```r rl_scopes() ``` -------------------------------- ### Red List information and statistics Source: https://docs.ropensci.org/rredlist/reference/index.html Functions to get Red List information, statistics, and manage API keys. ```APIDOC ## rl_sp_count() / rl_sp_count_() ### Description Get the count of species in the Red List. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_version() ### Description Get the Red List version. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_api_version() ### Description Get the Red List API version. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_citation() ### Description Get the citation for the Red List API. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ## rl_use_iucn() ### Description Helper function to get and save the IUCN API key. ### Method Not applicable (R function) ### Endpoint Not applicable (R function) ### Parameters (Specific parameters not detailed in source) ### Request Example (Not provided in source) ### Response (Specific response details not detailed in source) ```