Skip to content

Commit

Permalink
remove old code
Browse files Browse the repository at this point in the history
  • Loading branch information
knharrington committed Jul 1, 2024
1 parent 9e2a215 commit 1599354
Showing 1 changed file with 1 addition and 42 deletions.
43 changes: 1 addition & 42 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -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 &
Expand All @@ -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) %>%
Expand Down Expand Up @@ -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)
Expand All @@ -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) %>%
Expand All @@ -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) +
Expand Down

0 comments on commit 1599354

Please sign in to comment.