Project3/Vis_Function.R

#' Generates a color-blind friendly map based on locations from a dataframe generated by Pull__Cort
#' 
#' Generates a map of taxa based on locations provided by a dataframe generated by the Pull__Cort function. Plot points are colored according to the phrase used to search for taxa in the origional function, and labels are based on the scientific name, author, and year reported if all are available.
#'  
#' @param df A dataframe generated by Pull_Cort you'd like to map
#' @export ColorMap

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

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