get_species_locations: List the locations available for a species

View source: R/prepare_data.R

get_species_locationsR Documentation

List the locations available for a species

Description

This is a convenience function to list all available locations for a given species. By default, a data frame is returned with available countries, states and flyways

Usage

get_species_locations(
  df,
  species_code,
  type = c("country", "state", "flyway"),
  db_types = c("b", "r"),
  columns = NULL,
  sort_by = NULL,
  return_names = TRUE,
  return_codes = TRUE
)

get_species_countries(df, species_code, ...)

get_species_states(df, species_code, ...)

get_species_flyways(df, species_code, ...)

Arguments

df

The dataframe in which to search

species_code

The 4 letters short code for the desired species (as found in the SPEC column of the gb_banding dataset)

type

The type of data desired. Can be one of "country", "state" or "flyway", Default: c("country", "state", "flyway")

columns

The desired columns. By default returns all the location related columns: "country_name", "state_name" and "flyway"

sort_by

Column by which the results are sorted. Default: NULL, the results are unsorted

return_names

Return the name values of the desired columns? Default: TRUE

return_codes

Return the code values for the desired columns? Default: TRUE

db_type

The type of data desired, banding or recovery. Can take any value accepted by get_db_type but will only work for banding or recovery data, Default: c("b", "r")

Details

return_names and return_code will add the appropriate columns from the dataset. For example, if type is country, and return_names is set to TRUE, the function will return the column country_name if it is not already present in columns.

Value

If columns contains more than one element, a data frame with all available combinations of the selected columns. If columns contains only one element, a sorted vector of the unique values of the selected column

Functions

  • get_species_countries: Convenience functions to list all available countries for the given species.

  • get_species_states: Convenience functions to list all available states for the given species.

  • get_species_flyways: Convenience functions to list all available countries for the given species.

Examples

get_species_location("ATBR")

get_species_location("ATBR", "country_name")
# is equivalent to:
get_species_countries("ATBR")


Vin985/gblincoln documentation built on April 21, 2022, 1:49 a.m.