SearchingFunction.R

Onca <-
function(df){
  
  tot_merged <- unite(df, year_and_name, year, acceptedScientificName)
  
  levs <- factor(df$column_label)
  
  Mapss <- mutate(df, year_and_name = tot_merged$year_and_name)
  
  factpal <- colorFactor( palette = magma(length(levs)
                                          
  ), levs)
  
  Mapss %>% 
    
    group_by(scientificName) %>% 
    
    leaflet() %>%
    
    addTiles() %>% 
    
    addCircleMarkers(
      
      ~decimalLongitude, 
      
      ~decimalLatitude,
      
      color = ~factpal(column_label),
      
      stroke = FALSE, fillOpacity = 0.5, label = Mapss$year_and_name
      
    ) %>% addLegend(position = "bottomright", pal = factpal, values = ~column_label, title = "Taxa")}



Tigris <-
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)))
  
}


Animapx <-
function(A=NULL, B=NULL, C=NULL, D=NULL, E=NULL, F=NULL, G=NULL, H=NULL, I=NULL, J=NULL, K=NULL, L=NULL, M=NULL, N=NULL, O=NULL, P=NULL, Q=NULL, R=NULL, S=NULL, T=NULL){Onca(Tigris(c(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T)))}
W0650629/Project-3 documentation built on Dec. 2, 2019, 4:51 p.m.