This RMarkdown file includes the analysis on the snappers sampled overall for biometric measurements. Additionally, The brms package will not run when the conflicted package is installed, which is needed for certain functions in the dpylr package to work. So in this line of code I will do all the df subsetting steps which will be saved in the environment and can be used in the other scripts.

Load libraries

library(ggplot2)
library(conflicted)
## Warning: package 'conflicted' was built under R version 4.4.1
library(cowplot)
library(patchwork)
## Warning: package 'patchwork' was built under R version 4.4.1
library(summarytools)
## Warning: package 'summarytools' was built under R version 4.4.1
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ lubridate 1.9.3     ✔ tibble    3.2.1
## ✔ purrr     1.0.2     ✔ tidyr     1.3.1
library(viridis)
## Loading required package: viridisLite

Define color palettes

safe_colorblind_palette <- c("#88CCEE", "#CC6677", "#DDCC77", "#117733", "#332288", "#AA4499", "#44AA99", "#999933", "#882255", "#661100", "#6699CC", "#888888")

Load data file

“snapperdata_250624.csv” is the “WorkBook_OtolithProject_June_V1.9” file filtered to only include snappers.

snappers_df2506 <- read.csv("snapperdata_250624.csv")

#class categorical data as nominal factors
snappers_df2506$catch_month <- factor(snappers_df2506$catch_month)
snappers_df2506$year <- factor(snappers_df2506$year)
snappers_df2506$species <- factor(snappers_df2506$species)
snappers_df2506$common_name <- factor(snappers_df2506$common_name)
snappers_df2506$frozen <- factor(snappers_df2506$frozen)
snappers_df2506$catch_method <- factor(snappers_df2506$catch_method)
snappers_df2506$bait <- factor(snappers_df2506$bait)
snappers_df2506$area <- factor(snappers_df2506$area)
snappers_df2506$finclip <- factor(snappers_df2506$finclip)
snappers_df2506$otoliths <- factor(snappers_df2506$otoliths)
snappers_df2506$gutted <- factor(snappers_df2506$gutted)
snappers_df2506$gonads_present <- factor(snappers_df2506$gonads_present)
snappers_df2506$sex <- factor(snappers_df2506$sex)
snappers_df2506$maturity <- factor(snappers_df2506$maturity)

summary(snappers_df2506)
View(snappers_df2506)

Overall sampling length overview

plot_species_FL <-ggplot(snappers_df2506, aes(x = species, y = FL_CM)) + 
  geom_boxplot() + 
  geom_jitter(aes(fill = frozen, color = frozen), 
              size = 1.8, 
              alpha = 0.6, 
              pch = 21) + #show individual occurences 
  theme_classic() +
  coord_flip() +
  scale_x_discrete(name = "Species", 
                   labels = rev(str_wrap(c("E. oculatus (n=7)", 
                                       "L. bucanella (n=85)", 
                                       "L. synagris (n=31)", 
                                       "L. vivanus (n=88)", 
                                       "P. aquilonaris (n=24)", 
                                       "R. aurorubens (n=71)"), width = 14)),
                   limits = rev) +
  scale_y_continuous(name = "Fork Length in cm", limits = c(10,70))+
  scale_fill_viridis_d(name = "Frozen", 
                       option = "D", 
                       begin = 0.2, 
                       end = 0.8,
                       labels = c("Yes", "No")) +
  scale_color_viridis_d(guide = "none", 
                       option = "D", 
                       begin = 0.2, 
                       end = 0.8) +
  theme(axis.text.y=element_text(face = "italic")) +
  labs(title = "Sampled snappers (May 2023 to June 2024)") 

plot_species_FL

ggsave("snapperFLplot_2506.png", plot = plot_species_FL, width = 7.2, height = 3.8, dpi = 400)

Catch method overview

plot_species_method <- ggplot(snappers_df2506, aes(catch_method)) +
  theme_classic() +
  geom_bar(aes(fill = catch_method)) +
  scale_fill_viridis_d(option = "C", guide = "none", begin = 0, end = 0.4) +
  scale_x_discrete(name = "Catch Method", labels =str_wrap(c("Not recorded", "Dropline", "Lobster trap", "Redfish trap"),width = 10)) +
  scale_y_continuous(name = "Number of Individual Fish")+
  labs(title = "Snapper Sample Catch Methods")  +
  theme(axis.text=element_text(size=12),
        axis.title=element_text(size=14), 
        plot.title = element_text(size=16))

plot_species_method

ggsave("plot_species_method.png", plot = plot_species_method, width = 4, height = 3.4, dpi = 400)

Bait overview

plot_species_bait <- ggplot(snappers_df2506, aes(bait)) +
  theme_classic() +
  geom_bar(aes(fill = bait)) +
  scale_fill_viridis_d(option = "C", guide = "none", begin = 0.6, end = 1.0) +
  scale_x_discrete(name = "Bait Type", labels =str_wrap(c("Not recorded", "Cowskin", "Japanese bait", "Japanese bait/squid"), width = 10)) +
  scale_y_continuous(name = "Number of Individual Fish") +
  labs(title = "Snapper Sample Bait Types") +
  theme(axis.text=element_text(size=12),
        axis.title=element_text(size=14), 
        plot.title = element_text(size=16))

plot_species_bait

ggsave("plot_species_bait.png", plot = plot_species_bait, width = 4, height = 3.4, dpi = 400)
# Combine plots using plot_grid from cowplot
catchoverview_plot <- plot_grid(plot_species_method, plot_species_bait,
  ncol = 2,
align = "v")

# Display the combined plot
print(catchoverview_plot)

#save high res plot
ggsave("catchoverviewplot.png", plot = catchoverview_plot, width = 8, height = 4, dpi = 400)

Overall sex and maturity

conflicts_prefer(dplyr::filter)
## [conflicted] Will prefer dplyr::filter over any other package.
summary(snappers_df2506)
##   catch_date         catch_month  landing_time       dissection_date   
##  Length:309         Sep    :103   Length:309         Length:309        
##  Class :character   Jun    : 76   Class :character   Class :character  
##  Mode  :character   May    : 55   Mode  :character   Mode  :character  
##                     Jul    : 34                                        
##                     Apr    : 15                                        
##                            : 14                                        
##                     (Other): 12                                        
##  dissection_time      year        month             observer        
##  Length:309         2023:207   Length:309         Length:309        
##  Class :character   2024:102   Class :character   Class :character  
##  Mode  :character              Mode  :character   Mode  :character  
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                        species              common_name  fish_code        
##  Etelis oculatus           : 7   Blackfin Snapper :85   Length:309        
##  Lutjanus buccanella       :85   Lane Snapper     :31   Class :character  
##  Lutjanus synagris         :31   Queen Snapper    : 7   Mode  :character  
##  Lutjanus vivanus          :91   Vermilion Snapper:71                     
##  Pristipomoides aquilonaris:24   Wenchman Snapper :24                     
##  Rhomboplites aurorubens   :71   Yelloweye Snapper:91                     
##                                                                           
##  frozen        catch_method                   bait          area    
##  N: 99               :174                       :180          :105  
##  Y:210   Dropline    : 31   Cowskin             : 31   C2     : 71  
##          Lobster trap: 31   Japanese bait       : 66   B4     : 46  
##          Redfish trap: 73   Japanese bait; Squid: 32   D5     : 31  
##                                                        A3/A4  : 22  
##                                                        D3     : 20  
##                                                        (Other): 14  
##      SL_CM           FL_CM           TL_CM           HH_CM      
##  Min.   :13.70   Min.   :14.00   Min.   :14.90   Min.   :2.900  
##  1st Qu.:23.35   1st Qu.:21.60   1st Qu.:23.50   1st Qu.:4.725  
##  Median :27.00   Median :25.80   Median :28.50   Median :5.850  
##  Mean   :27.36   Mean   :27.02   Mean   :29.78   Mean   :6.026  
##  3rd Qu.:31.20   3rd Qu.:30.70   3rd Qu.:33.80   3rd Qu.:6.975  
##  Max.   :61.10   Max.   :65.50   Max.   :78.50   Max.   :9.900  
##  NA's   :173                     NA's   :14      NA's   :227    
##      ED_CM            W_G         finclip otoliths gutted  gonads_present
##  Min.   :0.800   Min.   :  52.7    :146   N :  6   N:302    :  6         
##  1st Qu.:1.425   1st Qu.: 163.5   N: 21   y :  2   Y:  7   N: 55         
##  Median :1.800   Median : 296.0   Y:142   Y :300           y:  2         
##  Mean   :1.828   Mean   : 437.8           Y :  1           Y:246         
##  3rd Qu.:2.200   3rd Qu.: 486.8                                          
##  Max.   :3.000   Max.   :4118.8                                          
##  NA's   :227     NA's   :6                                               
##  sex     maturity     G1L_CM           G2L_CM           GW_G          
##   :100    :207    Min.   : 1.000   Min.   : 0.000   Length:309        
##  F:117   A: 32    1st Qu.: 2.600   1st Qu.: 2.500   Class :character  
##  M: 92   B: 34    Median : 3.750   Median : 3.700   Mode  :character  
##          C: 34    Mean   : 4.196   Mean   : 4.204                     
##          D:  2    3rd Qu.: 5.000   3rd Qu.: 5.200                     
##                   Max.   :21.100   Max.   :22.800                     
##                   NA's   :63       NA's   :73                         
##  stomach._sample   
##  Length:309        
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 
#drop the columns with neither sex nor maturity measurements
snappers_reproduction <- snappers_df2506 %>%
  filter(maturity != "" | sex != "")

summary(snappers_reproduction)
##   catch_date         catch_month landing_time       dissection_date   
##  Length:213         Sep    :68   Length:213         Length:213        
##  Class :character   May    :55   Class :character   Class :character  
##  Mode  :character   Jun    :38   Mode  :character   Mode  :character  
##                     Jul    :21                                        
##                     Apr    :15                                        
##                            : 5                                        
##                     (Other):11                                        
##  dissection_time      year        month             observer        
##  Length:213         2023:111   Length:213         Length:213        
##  Class :character   2024:102   Class :character   Class :character  
##  Mode  :character              Mode  :character   Mode  :character  
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                        species              common_name  fish_code        
##  Etelis oculatus           : 4   Blackfin Snapper :55   Length:213        
##  Lutjanus buccanella       :55   Lane Snapper     :31   Class :character  
##  Lutjanus synagris         :31   Queen Snapper    : 4   Mode  :character  
##  Lutjanus vivanus          :44   Vermilion Snapper:55                     
##  Pristipomoides aquilonaris:24   Wenchman Snapper :24                     
##  Rhomboplites aurorubens   :55   Yelloweye Snapper:44                     
##                                                                           
##  frozen        catch_method                   bait         area   
##  N: 99               :82                        :88          :45  
##  Y:114   Dropline    :28    Cowskin             :31   B4     :42  
##          Lobster trap:31    Japanese bait       :66   C2     :39  
##          Redfish trap:72    Japanese bait; Squid:28   D5     :31  
##                                                       A3/A4  :22  
##                                                       D3     :20  
##                                                       (Other):14  
##      SL_CM           FL_CM           TL_CM           HH_CM      
##  Min.   :13.70   Min.   :14.50   Min.   :15.80   Min.   :2.900  
##  1st Qu.:23.35   1st Qu.:21.80   1st Qu.:23.48   1st Qu.:4.725  
##  Median :27.00   Median :27.00   Median :29.60   Median :5.850  
##  Mean   :27.41   Mean   :27.68   Mean   :30.42   Mean   :6.026  
##  3rd Qu.:31.23   3rd Qu.:32.40   3rd Qu.:35.42   3rd Qu.:6.975  
##  Max.   :61.10   Max.   :65.50   Max.   :78.50   Max.   :9.900  
##  NA's   :81                      NA's   :9       NA's   :131    
##      ED_CM            W_G         finclip otoliths gutted  gonads_present
##  Min.   :0.800   Min.   :  52.7    : 60   N :  5   N:211    :  1         
##  1st Qu.:1.425   1st Qu.: 164.7   N: 21   y :  2   Y:  2   N:  1         
##  Median :1.800   Median : 334.6   Y:132   Y :205           y:  2         
##  Mean   :1.828   Mean   : 468.7           Y :  1           Y:209         
##  3rd Qu.:2.200   3rd Qu.: 566.5                                          
##  Max.   :3.000   Max.   :4118.8                                          
##  NA's   :131     NA's   :5                                               
##  sex     maturity     G1L_CM           G2L_CM           GW_G          
##   :  4    :111    Min.   : 1.000   Min.   : 0.000   Length:213        
##  F:117   A: 32    1st Qu.: 2.800   1st Qu.: 2.675   Class :character  
##  M: 92   B: 34    Median : 3.900   Median : 3.950   Mode  :character  
##          C: 34    Mean   : 4.361   Mean   : 4.398                     
##          D:  2    3rd Qu.: 5.125   3rd Qu.: 5.400                     
##                   Max.   :21.100   Max.   :22.800                     
##                   NA's   :1        NA's   :9                          
##  stomach._sample   
##  Length:213        
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 
#drop the columns without sex measurements
snappers_sex <- snappers_df2506 %>%
  filter(sex != "")
summary(snappers_sex)
##   catch_date         catch_month landing_time       dissection_date   
##  Length:209         Sep    :68   Length:209         Length:209        
##  Class :character   May    :54   Class :character   Class :character  
##  Mode  :character   Jun    :36   Mode  :character   Mode  :character  
##                     Jul    :21                                        
##                     Apr    :14                                        
##                            : 5                                        
##                     (Other):11                                        
##  dissection_time      year        month             observer        
##  Length:209         2023:111   Length:209         Length:209        
##  Class :character   2024: 98   Class :character   Class :character  
##  Mode  :character              Mode  :character   Mode  :character  
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                        species              common_name  fish_code        
##  Etelis oculatus           : 4   Blackfin Snapper :53   Length:209        
##  Lutjanus buccanella       :53   Lane Snapper     :31   Class :character  
##  Lutjanus synagris         :31   Queen Snapper    : 4   Mode  :character  
##  Lutjanus vivanus          :43   Vermilion Snapper:55                     
##  Pristipomoides aquilonaris:23   Wenchman Snapper :23                     
##  Rhomboplites aurorubens   :55   Yelloweye Snapper:43                     
##                                                                           
##  frozen        catch_method                   bait         area   
##  N: 96               :82                        :88          :45  
##  Y:113   Dropline    :28    Cowskin             :30   B4     :41  
##          Lobster trap:30    Japanese bait       :63   C2     :39  
##          Redfish trap:69    Japanese bait; Squid:28   D5     :30  
##                                                       A3/A4  :22  
##                                                       D3     :19  
##                                                       (Other):13  
##      SL_CM           FL_CM           TL_CM           HH_CM      
##  Min.   :13.70   Min.   :14.50   Min.   :15.80   Min.   :2.900  
##  1st Qu.:23.55   1st Qu.:22.00   1st Qu.:23.57   1st Qu.:4.800  
##  Median :27.25   Median :27.20   Median :29.60   Median :6.000  
##  Mean   :27.60   Mean   :27.76   Mean   :30.50   Mean   :6.097  
##  3rd Qu.:31.32   3rd Qu.:32.60   3rd Qu.:35.52   3rd Qu.:7.000  
##  Max.   :61.10   Max.   :65.50   Max.   :78.50   Max.   :9.900  
##  NA's   :81                      NA's   :9       NA's   :130    
##      ED_CM            W_G         finclip otoliths gutted  gonads_present
##  Min.   :0.800   Min.   :  52.7    : 60   N :  5   N:207    :  1         
##  1st Qu.:1.500   1st Qu.: 169.2   N: 21   y :  2   Y:  2   N:  0         
##  Median :1.800   Median : 334.6   Y:128   Y :201           y:  2         
##  Mean   :1.844   Mean   : 472.7           Y :  1           Y:206         
##  3rd Qu.:2.250   3rd Qu.: 578.7                                          
##  Max.   :3.000   Max.   :4118.8                                          
##  NA's   :130     NA's   :5                                               
##  sex     maturity     G1L_CM           G2L_CM           GW_G          
##   :  0    :111    Min.   : 1.000   Min.   : 0.000   Length:209        
##  F:117   A: 28    1st Qu.: 2.800   1st Qu.: 2.700   Class :character  
##  M: 92   B: 34    Median : 3.900   Median : 4.000   Mode  :character  
##          C: 34    Mean   : 4.387   Mean   : 4.412                     
##          D:  2    3rd Qu.: 5.200   3rd Qu.: 5.400                     
##                   Max.   :21.100   Max.   :22.800                     
##                                    NA's   :7                          
##  stomach._sample   
##  Length:209        
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 
#drop the columns without maturity measurements
snappers_maturity <- snappers_df2506 %>%
  filter(maturity != "")

summary(snappers_maturity)
##   catch_date         catch_month landing_time       dissection_date   
##  Length:102         May    :55   Length:102         Length:102        
##  Class :character   Jun    :27   Class :character   Class :character  
##  Mode  :character   Apr    :15   Mode  :character   Mode  :character  
##                     Mar    : 5                                        
##                            : 0                                        
##                     Aug    : 0                                        
##                     (Other): 0                                        
##  dissection_time      year        month             observer        
##  Length:102         2023:  0   Length:102         Length:102        
##  Class :character   2024:102   Class :character   Class :character  
##  Mode  :character              Mode  :character   Mode  :character  
##                                                                     
##                                                                     
##                                                                     
##                                                                     
##                        species              common_name  fish_code        
##  Etelis oculatus           : 0   Blackfin Snapper :33   Length:102        
##  Lutjanus buccanella       :33   Lane Snapper     :19   Class :character  
##  Lutjanus synagris         :19   Queen Snapper    : 0   Mode  :character  
##  Lutjanus vivanus          :29   Vermilion Snapper:13                     
##  Pristipomoides aquilonaris: 8   Wenchman Snapper : 8                     
##  Rhomboplites aurorubens   :13   Yelloweye Snapper:29                     
##                                                                           
##  frozen       catch_method                   bait         area   
##  N:99               : 0                        : 5   D5     :31  
##  Y: 3   Dropline    : 0    Cowskin             :31   A3/A4  :22  
##         Lobster trap:31    Japanese bait       :66   D3     :19  
##         Redfish trap:71    Japanese bait; Squid: 0   B4     :13  
##                                                      D4     : 4  
##                                                             : 3  
##                                                      (Other):10  
##      SL_CM           FL_CM           TL_CM           HH_CM      
##  Min.   :13.70   Min.   :16.10   Min.   :16.90   Min.   :2.900  
##  1st Qu.:21.85   1st Qu.:25.00   1st Qu.:27.18   1st Qu.:4.725  
##  Median :25.40   Median :29.05   Median :31.30   Median :5.850  
##  Mean   :25.88   Mean   :29.48   Mean   :31.87   Mean   :6.026  
##  3rd Qu.:29.32   3rd Qu.:33.17   3rd Qu.:36.40   3rd Qu.:6.975  
##  Max.   :38.60   Max.   :44.10   Max.   :47.60   Max.   :9.900  
##                                                  NA's   :20     
##      ED_CM            W_G         finclip otoliths gutted  gonads_present
##  Min.   :0.800   Min.   :  65.7    : 0    N :  0   N:100    : 0          
##  1st Qu.:1.425   1st Qu.: 238.9   N:18    y :  2   Y:  2   N: 1          
##  Median :1.800   Median : 401.4   Y:84    Y :100           y: 2          
##  Mean   :1.828   Mean   : 516.7           Y :  0           Y:99          
##  3rd Qu.:2.200   3rd Qu.: 632.8                                          
##  Max.   :3.000   Max.   :1714.7                                          
##  NA's   :20                                                              
##  sex    maturity     G1L_CM           G2L_CM           GW_G          
##   : 4    : 0     Min.   : 1.000   Min.   : 1.000   Length:102        
##  F:47   A:32     1st Qu.: 2.800   1st Qu.: 2.700   Class :character  
##  M:51   B:34     Median : 3.900   Median : 4.000   Mode  :character  
##         C:34     Mean   : 4.399   Mean   : 4.521                     
##         D: 2     3rd Qu.: 5.300   3rd Qu.: 5.800                     
##                  Max.   :11.500   Max.   :11.600                     
##                  NA's   :1        NA's   :5                          
##  stomach._sample   
##  Length:102        
##  Class :character  
##  Mode  :character  
##                    
##                    
##                    
## 

Filter the data into counts

female_counts <- snappers_reproduction %>%
  filter(sex == "F") %>%
  group_by(species, maturity) %>%
  summarize(count = n(), .groups = 'drop') %>%
  mutate(sex = "Female")

# Calculate counts for males
male_counts <- snappers_reproduction %>%
  filter(sex == "M") %>%
  group_by(species, maturity) %>%
  summarize(count = n(), .groups = 'drop') %>%
  mutate(sex = "Male")

# Calculate counts for N/A
na_counts <- snappers_reproduction %>%
  filter(sex == "") %>%
  group_by(species, maturity) %>%
  summarize(count = n(), .groups = 'drop') %>%
  mutate(sex = "N/A")

# Combine the counts into one dataframe
summary_reproduction <- bind_rows(female_counts, male_counts, na_counts)

# View the combined dataframe
View(summary_reproduction)

Plot

plasma_colors_5 <- rev(viridis_pal(option = "plasma", begin = 0.1, end = 0.9)(5))
plasma_colors_5
## [1] "#FCCE25FF" "#F1844BFF" "#CC4678FF" "#900DA4FF" "#42049EFF"
# First plot with the first three species
reproduction_top_plot <- ggplot(summary_reproduction %>% filter(species %in% c("Etelis oculatus", "Lutjanus buccanella", "Lutjanus synagris"))) +
  geom_bar(aes(x = sex, y = count, fill = maturity),
           position = "stack",
           stat = "identity") +
  facet_grid(~ species, switch = "x") +
  theme_minimal() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill = NA, color = "transparent"),
        panel.spacing = unit(-.01, "cm"),
        strip.text = element_text(face = "italic")) +
  scale_fill_manual(values = c("#FCCE25FF", "#F1844BFF", "#CC4678FF", "#900DA4FF"),
                    label = c("N/A", "A", "B", "C")) +
  labs(x = "", 
       y = "Count",
       fill = "Maturity stage")

# Second plot with the next three species
reproduction_bottom_plot <- ggplot(summary_reproduction %>% filter(species %in% c("Lutjanus vivanus", "Pristipomoides aquilonaris", "Rhomboplites aurorubens"))) +
  geom_bar(aes(x = sex, y = count, fill = maturity),
           position = "stack",
           stat = "identity") +
  facet_grid(~ species, switch = "x") +
  theme_minimal() +
  theme(strip.placement = "outside",
        strip.background = element_rect(fill = NA, color = "transparent"),
        panel.spacing = unit(-.01, "cm"),
        strip.text = element_text(face = "italic")) +
  scale_fill_manual(values = c("#FCCE25FF", "#F1844BFF", "#CC4678FF", "#900DA4FF", "#42049EFF"),
                    label = c("N/A", "A", "B", "C", "D")) +
  labs(x = "", 
       y = "Count",
       fill = "Maturity stage")

# Combine the two plots vertically
reproduction_plot <- reproduction_top_plot / reproduction_bottom_plot

# View the combined plot
reproduction_plot

# Save the plot
ggsave("reproduction_plot.png", plot = reproduction_plot, width = 7.2, height = 6, dpi = 400)

Subset the BS data into a new df

conflicts_prefer(dplyr::filter)
## [conflicted] Removing existing preference.
## [conflicted] Will prefer dplyr::filter over any other package.
bsdf_2506 <- subset(filter(snappers_df2506, species == "Lutjanus buccanella"))

#save the df as a csv for further steps
write.csv(bsdf_2506, "bs2506df.csv")

Subset the YS data into a new df

ysdf_2506 <- filter(snappers_df2506, species == "Lutjanus vivanus")
View(ysdf_2506)

#remove gutted samples
ysdf_2506 <- subset(filter(ysdf_2506, gutted == "N"))

summary(ysdf_2506)
##   catch_date         catch_month landing_time       dissection_date   
##  Length:86          Sep    :32   Length:86          Length:86         
##  Class :character   Jun    :19   Class :character   Class :character  
##  Mode  :character   May    :14   Mode  :character   Mode  :character  
##                     Jul    : 9                                        
##                     Mar    : 5                                        
##                            : 3                                        
##                     (Other): 4                                        
##  dissection_time      year       month             observer        
##  Length:86          2023:57   Length:86          Length:86         
##  Class :character   2024:29   Class :character   Class :character  
##  Mode  :character             Mode  :character   Mode  :character  
##                                                                    
##                                                                    
##                                                                    
##                                                                    
##                        species              common_name  fish_code        
##  Etelis oculatus           : 0   Blackfin Snapper : 0   Length:86         
##  Lutjanus buccanella       : 0   Lane Snapper     : 0   Class :character  
##  Lutjanus synagris         : 0   Queen Snapper    : 0   Mode  :character  
##  Lutjanus vivanus          :86   Vermilion Snapper: 0                     
##  Pristipomoides aquilonaris: 0   Wenchman Snapper : 0                     
##  Rhomboplites aurorubens   : 0   Yelloweye Snapper:86                     
##                                                                           
##  frozen       catch_method                   bait         area   
##  N:26               :48                        :54          :25  
##  Y:60   Dropline    : 8    Cowskin             : 1   C2     :24  
##         Lobster trap: 1    Japanese bait       :23   B4     :13  
##         Redfish trap:29    Japanese bait; Squid: 8   D5     :13  
##                                                      D3     : 6  
##                                                      A3/A4  : 5  
##                                                      (Other): 0  
##      SL_CM           FL_CM           TL_CM           HH_CM           ED_CM     
##  Min.   :16.00   Min.   :17.20   Min.   :18.30   Min.   :3.600   Min.   :1.20  
##  1st Qu.:24.68   1st Qu.:21.73   1st Qu.:23.20   1st Qu.:5.250   1st Qu.:1.65  
##  Median :29.20   Median :26.15   Median :28.60   Median :6.600   Median :1.90  
##  Mean   :28.70   Mean   :27.57   Mean   :29.77   Mean   :6.317   Mean   :1.87  
##  3rd Qu.:32.10   3rd Qu.:33.08   3rd Qu.:36.08   3rd Qu.:7.450   3rd Qu.:2.10  
##  Max.   :40.40   Max.   :45.90   Max.   :49.20   Max.   :9.400   Max.   :3.00  
##  NA's   :48                                      NA's   :63      NA's   :63    
##       W_G         finclip otoliths gutted gonads_present sex    maturity
##  Min.   :  83.9    :47    N : 0    N:86    : 0            :43    :57    
##  1st Qu.: 162.7   N: 5    y : 1    Y: 0   N:28           F:22   A:13    
##  Median : 281.9   Y:34    Y :84           y: 1           M:21   B:12    
##  Mean   : 429.0           Y : 1           Y:57                  C: 2    
##  3rd Qu.: 583.3                                                 D: 2    
##  Max.   :1714.7                                                         
##                                                                         
##      G1L_CM           G2L_CM           GW_G           stomach._sample   
##  Min.   : 1.000   Min.   : 0.000   Length:86          Length:86         
##  1st Qu.: 2.250   1st Qu.: 2.200   Class :character   Class :character  
##  Median : 3.800   Median : 3.600   Mode  :character   Mode  :character  
##  Mean   : 4.441   Mean   : 4.261                                        
##  3rd Qu.: 5.950   3rd Qu.: 5.500                                        
##  Max.   :11.500   Max.   :11.600                                        
##  NA's   :27       NA's   :29
#save the df as a csv for further steps
write.csv(ysdf_2506, "ys2506df.csv")

Subset the VS data into a new df

vsdf_2506 <- filter(snappers_df2506, species == "Rhomboplites aurorubens")

#remove the columns with no weight measurements
vsdf_2506 <- vsdf_2506 %>% drop_na(W_G)

#remove the columns with no TL_CM measurements
vsdf_2506 <- vsdf_2506 %>% drop_na(TL_CM)

#remove gutted samples
vsdf_2506 <- subset(filter(vsdf_2506, gutted == "N"))

View(vsdf_2506)
summary(vsdf_2506)
##   catch_date         catch_month landing_time       dissection_date   
##  Length:61          Sep    :31   Length:61          Length:61         
##  Class :character   Jun    :15   Class :character   Class :character  
##  Mode  :character   Jul    : 9   Mode  :character   Mode  :character  
##                     May    : 5                                        
##                     Apr    : 1                                        
##                            : 0                                        
##                     (Other): 0                                        
##  dissection_time      year       month             observer        
##  Length:61          2023:49   Length:61          Length:61         
##  Class :character   2024:12   Class :character   Class :character  
##  Mode  :character             Mode  :character   Mode  :character  
##                                                                    
##                                                                    
##                                                                    
##                                                                    
##                        species              common_name  fish_code        
##  Etelis oculatus           : 0   Blackfin Snapper : 0   Length:61         
##  Lutjanus buccanella       : 0   Lane Snapper     : 0   Class :character  
##  Lutjanus synagris         : 0   Queen Snapper    : 0   Mode  :character  
##  Lutjanus vivanus          : 0   Vermilion Snapper:61                     
##  Pristipomoides aquilonaris: 0   Wenchman Snapper : 0                     
##  Rhomboplites aurorubens   :61   Yelloweye Snapper: 0                     
##                                                                           
##  frozen       catch_method                   bait         area   
##  N:12               :49                        :49   C2     :30  
##  Y:49   Dropline    : 0    Cowskin             : 0          :19  
##         Lobster trap: 0    Japanese bait       :12   D5     : 9  
##         Redfish trap:12    Japanese bait; Squid: 0   D3     : 2  
##                                                      D4     : 1  
##                                                      A3/A4  : 0  
##                                                      (Other): 0  
##      SL_CM           FL_CM           TL_CM           HH_CM      
##  Min.   :16.90   Min.   :14.00   Min.   :14.90   Min.   :3.400  
##  1st Qu.:18.70   1st Qu.:16.50   1st Qu.:17.90   1st Qu.:3.700  
##  Median :19.40   Median :19.90   Median :21.60   Median :4.000  
##  Mean   :20.98   Mean   :20.76   Mean   :22.81   Mean   :4.245  
##  3rd Qu.:24.00   3rd Qu.:25.20   3rd Qu.:28.00   3rd Qu.:4.800  
##  Max.   :27.00   Max.   :29.90   Max.   :34.50   Max.   :5.600  
##  NA's   :48                                      NA's   :50     
##      ED_CM            W_G        finclip otoliths gutted gonads_present sex   
##  Min.   :1.100   Min.   : 52.7    :29    N : 0    N:61    : 0            :12  
##  1st Qu.:1.500   1st Qu.: 81.4   N: 3    y : 0    Y: 0   N: 5           F:33  
##  Median :1.600   Median :132.2   Y:29    Y :61           y: 0           M:16  
##  Mean   :1.618   Mean   :182.6           Y : 0           Y:56                 
##  3rd Qu.:1.800   3rd Qu.:281.2                                                
##  Max.   :2.100   Max.   :481.6                                                
##  NA's   :50                                                                   
##  maturity     G1L_CM          G2L_CM          GW_G           stomach._sample   
##   :49     Min.   :1.000   Min.   :0.500   Length:61          Length:61         
##  A: 0     1st Qu.:2.500   1st Qu.:2.300   Class :character   Class :character  
##  B: 4     Median :3.500   Median :3.200   Mode  :character   Mode  :character  
##  C: 8     Mean   :3.668   Mean   :3.532                                        
##  D: 0     3rd Qu.:4.600   3rd Qu.:4.800                                        
##           Max.   :6.500   Max.   :6.500                                        
##           NA's   :8       NA's   :8
#save the df as a csv for further steps
write.csv(vsdf_2506, "vs2506df.csv")

Subset the LS data into a new df

lsdf_2506 <- filter(snappers_df2506, species == "Lutjanus synagris")

#remove the columns with no weight measurements
lsdf_2506 <- lsdf_2506 %>% drop_na(W_G)

#remove gutted samples
lsdf_2506 <- subset(filter(lsdf_2506, gutted == "N"))

View(lsdf_2506)

#save the df as a csv for further steps
write.csv(lsdf_2506, "ls2506df.csv")

Subset the WRN data into a new df

wrndf_2506 <- filter(snappers_df2506, species == "Pristipomoides aquilonaris")

#remove the columns with no weight measurements
wrndf_2506 <- wrndf_2506 %>% drop_na(W_G)

#remove gutted samples
wrndf_2506 <- subset(filter(wrndf_2506, gutted == "N"))

View(wrndf_2506)

#save the df as a csv for further steps
write.csv(wrndf_2506, "wrn2506df.csv")

Subset the QS data into a new df

qsdf_2506 <- filter(snappers_df2506, species == "Etelis oculatus")
View(qsdf_2506)

summary(qsdf_2506)
##   catch_date         catch_month landing_time       dissection_date   
##  Length:7           Sep    :7    Length:7           Length:7          
##  Class :character          :0    Class :character   Class :character  
##  Mode  :character   Apr    :0    Mode  :character   Mode  :character  
##                     Aug    :0                                         
##                     Dec    :0                                         
##                     Jul    :0                                         
##                     (Other):0                                         
##  dissection_time      year      month             observer        
##  Length:7           2023:7   Length:7           Length:7          
##  Class :character   2024:0   Class :character   Class :character  
##  Mode  :character            Mode  :character   Mode  :character  
##                                                                   
##                                                                   
##                                                                   
##                                                                   
##                        species             common_name  fish_code        
##  Etelis oculatus           :7   Blackfin Snapper :0    Length:7          
##  Lutjanus buccanella       :0   Lane Snapper     :0    Class :character  
##  Lutjanus synagris         :0   Queen Snapper    :7    Mode  :character  
##  Lutjanus vivanus          :0   Vermilion Snapper:0                      
##  Pristipomoides aquilonaris:0   Wenchman Snapper :0                      
##  Rhomboplites aurorubens   :0   Yelloweye Snapper:0                      
##                                                                          
##  frozen       catch_method                   bait        area       SL_CM      
##  N:0                :0                         :0   B4     :7   Min.   :22.00  
##  Y:7    Dropline    :7     Cowskin             :0          :0   1st Qu.:25.80  
##         Lobster trap:0     Japanese bait       :0   A3/A4  :0   Median :31.30  
##         Redfish trap:0     Japanese bait; Squid:7   A4/A5  :0   Mean   :37.57  
##                                                     B3     :0   3rd Qu.:48.50  
##                                                     B3/4   :0   Max.   :61.10  
##                                                     (Other):0                  
##      FL_CM           TL_CM           HH_CM         ED_CM          W_G        
##  Min.   :23.50   Min.   :28.60   Min.   : NA   Min.   : NA   Min.   : 228.2  
##  1st Qu.:27.85   1st Qu.:34.30   1st Qu.: NA   1st Qu.: NA   1st Qu.: 379.9  
##  Median :33.30   Median :41.70   Median : NA   Median : NA   Median : 618.8  
##  Mean   :40.27   Mean   :50.17   Mean   :NaN   Mean   :NaN   Mean   :1440.1  
##  3rd Qu.:51.95   3rd Qu.:66.90   3rd Qu.: NA   3rd Qu.: NA   3rd Qu.:2177.8  
##  Max.   :65.50   Max.   :78.50   Max.   : NA   Max.   : NA   Max.   :4118.8  
##                                  NA's   :7     NA's   :7                     
##  finclip otoliths gutted gonads_present sex   maturity     G1L_CM     
##   :0     N :0     N:7     :0             :3    :7      Min.   : 4.10  
##  N:0     y :0     Y:0    N:0            F:4   A:0      1st Qu.: 5.70  
##  Y:7     Y :7            y:0            M:0   B:0      Median : 6.40  
##          Y :0            Y:7                  C:0      Mean   :10.01  
##                                               D:0      3rd Qu.:13.55  
##                                                        Max.   :21.10  
##                                                                       
##      G2L_CM          GW_G           stomach._sample   
##  Min.   : 3.80   Length:7           Length:7          
##  1st Qu.: 5.65   Class :character   Class :character  
##  Median : 7.10   Mode  :character   Mode  :character  
##  Mean   :10.36                                        
##  3rd Qu.:13.75                                        
##  Max.   :22.80                                        
## 
#save the df as a csv for further steps
write.csv(qsdf_2506, "qs2506df.csv")