Finds common names for taxa based on highest frequency of occurrence in data using make_attribute. Compared to a straight run of make_attribute, this function first attempts to match a taxa to a common name based on only common names belonging to taxa names of the same rank (i.e. species names will only be matched to species level common names if they occur in the data). Taxa that cannot be matched to a common name at their taxonomic rank will be given a common name from a lower level (e.g. a species without a species level match will be given the most frequently occurring subspecies common name).

make_common(
  df,
  taxa_col = "original_name",
  common_col = "common",
  taxonomy = taxonomy,
  max_guess = "species",
  context = "kingdom",
  remove_strings = c("n/a", "''", "NA", "N/A", "^\\s*$"),
  use_aoi = NULL,
  df_x = "long",
  df_y = "lat",
  crs_df = 4326
)

Arguments

df

Dataframe with taxa_col and common_col, and optionally x, y coordinate columns if use_aoi == TRUE.

taxa_col

Character name of column in df that was passed to get_taxonomy as taxa_col.

common_col

Character name of column in df that contains the common names.

taxonomy

List resulting from call to make_taxonomy().

max_guess

Character. If common name values are not available for taxa, try guessing from values up to max_guess level of taxonomic hierarchy. See lurank. Note it does not make sense to provide a rank here that is lower than the target_rank provided to make_taxonomy when taxonomy was made.

context

Any other columns in df to maintain throughout summarising.

remove_strings

Character. Any values in common_col to exclude.

use_aoi

sf. Name of sf object for filtering data for common name generation using envClean::filter_geo_range.

df_x

Character. Name of column with x coordinate.

df_y

Character. Name of column with y coordinate.

crs_df

Anything that will return a legitimate crs when passed to the crs attribute of st_transform or st_as_sf.

Value

Dataframe with one row for each taxa with best guess at a common name based on the values in common_col.