R/Query_Function.R

Defines functions Pull__Cort

Documented in Pull__Cort

#' Creates a dataframe of geospatial data from GBIF
#' 
#' Creates an easy to manipulate dataframe based on geospatial data from GBIF based on a vector of provided taxa.
#'  
#' @param df A vector of taxa you want you  want geospatial data on
#' @return return(Taxa_Frame %>% filter(!is.na(country)) Creates a data frame and removes rows where country is NA
#' @export Pull__Cort

Pull__Cort <-
function(taxvec){
  ids <- c()
  for (taxo in taxvec){
    print(taxo)
    cleaned <- name_suggest(taxo)
    print(cleaned)
    ids[taxo] <- c(cleaned$key)
  }  
  df <- lapply(ids, occ_search, return = "data")   
  Taxa_Frame <- bind_rows(df, .id = "column_label")   
  return(Taxa_Frame %>% filter(!is.na(country)))
}


#This function requires tidyverse, dplyr, and rgbif libraries.
W0650629/Project-3 documentation built on Dec. 2, 2019, 4:51 p.m.