library(tidyverse)
library(rfishbase)
#' @export
#' @title Check for alternate versions of a scientific name and return the scientific names FishBase recognizes as valid
#'
#' @description This is the `validate_names` function from FishBase package
#' @param a string of scientific names
#' @return a string of the validated names or NA if not found in FishBase
fishbase_names_check <- function(species_name) {
fishbase_name=rfishbase::validate_names(species_name)
if(identical(fishbase_name, character(0))) {
fishbase_name=NA
}
return(fishbase_name)
}
#' @export
#' @title Verify against FishBase the species names of BOLD specimen
#'
#' @description Add a column named `fishbase_species_name` to a curated BOLD specimen dataframe.
#' This column gives the species name used to identify the specimen in FishBase
#' If the specimen BOLD species name is not found in FishBase, then a NA value is given.
#'
#' @param datGeoSpecMarkSeqClean A curated dataframe generated by `prepare_bold_res` function from rgeogendiv package
#' with 80 columns including:
#' `species_name`: this column is a list of string object. The only one necessary to validate species name on FishBase.
#' @return A data.frame with a supplementary column `fishbase_species_name`.
#' This column is a list of strings.
#' It gives synonyms of species names used by FishBase to describe BOLD specimen.
#' If the specimen BOLD species name is not found in FishBase, then a NA value is given.
#'
fishbase_verify_bold_species <- function(datGeoSpecMarkSeqClean) {
datGeoSpecMarkSeqFish <- datGeoSpecMarkSeqClean %>%
dplyr::mutate(fishbase_species_name=as.character(lapply(species_name, fishbase_names_check)))
return(datGeoSpecMarkSeqFish)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.