diff --git a/global.R b/global.R index 73ea80a..3c0a545 100644 --- a/global.R +++ b/global.R @@ -7,65 +7,37 @@ # load packages { library(tidyverse) - #library(plyr) library(data.table) library(janitor) - #library(doBy) library(spatial) - library(sp) library(sf) library(spdep) library(sfdep) library(fields) library(terra) - #library(rasterVis) - #library(raster) - library(RColorBrewer) library(viridis) library(leaflet) - #library(kableExtra) library(shiny) - #library(plotly) library(htmlwidgets) library(shinythemes) library(shinycustomloader) library(leaflet.extras2) - #library(leafem) - - #library(rjson) - #library(KernSmooth) - #library(ks) } -#cleanMem <- function(n=10) { for (i in 1:n) gc() } - # Most recent export -Data.In <- data.table::fread("data/allsharks.csv") - -#My.Vessel <- "No Bull" +Data.In <- fread("data/allsharks.csv") #Subset for time My.Date.Start <- as.Date("2015-06-01", format = "%Y-%m-%d") My.Date.End <- as.Date("2024-12-31", format = "%Y-%m-%d") -#My.Months <- c(1,2,3,4,5,6,7,8,9,10,11,12) - #Subset for fishery My.Trip.Type <- c("Longline") -# # Species Lookup Table -# Species.Lookup <- read.csv("data/EM Species Codes Lookup.csv") -# # Modify species lookup -# Species.Lookup = plyr::rename(Species.Lookup, c("Number"="Species.Number")) -# colnames(Species.Lookup)=gsub(".","_",colnames(Species.Lookup), fixed=T) -# Species.Lookup$Species_Lookup = gsub("/"," or ",Species.Lookup$Species_Lookup) - -#My.species = Species.Lookup[Species.Lookup$Shark == "Y",]$Species.Number - # Combine filter conditions All.Data.Final <- setDT(Data.In[Data.In$Retrieval_Begin_Date > My.Date.Start & Data.In$Retrieval_Begin_Date < My.Date.End & @@ -90,12 +62,6 @@ top_species <- setDT(All.Data.Final)[, .N, by = .(Retrieval_Year, Common_Name)][ top_species_all_years_allsharks <- names(sort(tapply(top_species$N, top_species$Common_Name, sum), decreasing = TRUE))[1:10] top.sub <- All.Data.Final[Common_Name %in% top_species_all_years_allsharks] -# Create a copy of top.sub for further processing -#top.sub2 <- copy(top.sub) - -# species caught table -#Species.Count <- summaryBy(Species_Number ~ Common_Name, data=unique(All.Data.Final[,c("Species_Number","Common_Name")]), FUN=c(length)) %>% - #dplyr::summarise(Number_of_Unique_Species_Groups = sum(Species_Number.length)) All.Species <- All.Data.Final %>% dplyr::group_by(Common_Name) %>% @@ -123,11 +89,6 @@ gridshp <- st_read(dsn="shapefiles", layer = "GOM_GRID_10MIN_fullgulf") gridshp=gridshp[1] names(gridshp)[names(gridshp) == "Id"] <- "GRID_ID" -#gearrest <- st_read(dsn="shapefiles", layer="shapefile_reef_fish_longline_buoy_gear_po_GOMx_SERO") -#gearrest <- st_transform(gearrest, crs=4326) -#seasonalclose <- st_read(dsn="shapefiles", layer="Gulf_ReefLL_seasonal_po") -#seasonalclose <- st_transform(seasonalclose, crs=4326) - # home port lats <- c(27.332160) lons <- c(-82.577740) @@ -138,7 +99,6 @@ port_icon <- makeIcon("www/MoteLogomark.svg", iconWidth=30, iconHeight=30, iconAnchorX=15, iconAnchorY=15) -# Vessel activity over time # Calculate the number of unique retrievals per unique trip unique_retrievals <- All.Data.Final %>% dplyr::group_by(Retrieval_Year) %>% @@ -156,7 +116,6 @@ summary_data <- All.Data.Final %>% # Merge the summary data with the number of unique retrievals summary_data <- left_join(summary_data, unique_retrievals, by = "Retrieval_Year") - summarylinechart <- ggplot(summary_data) + geom_point(aes(x = Retrieval_Year, y = Sea_Days_sum, color = "Sea Days"), size = 2) + geom_point(aes(x = Retrieval_Year, y = Number_Trips, color = "Trips"), size = 2) +