based on June 27, 2016 document “Database_starting”

Notes on data formatting and directory control etc:

libraries you will need (and therefore, packagse to download if you don’t have them already)

Import data and rename variables

setwd("C:/Users/theco/Desktop/Fish Database Project")

database <- read.csv("database_0806.csv") ## change the name here to whatever you call the database

database <- database %>% rename(d15N = d15N.avg., 
                   d13C = d13C.avg.,  
                   length = Length..mm..avg., 
                   baseline_d15N = Baselined15N,
                   ecology = FeedingHabits, 
                   TL_fishbase = FishBase.Trophic.Level, 
                   lat = Lat, 
                   long = Long, 
                   stationlocationdata = StationLocationData) #.eitherestimatedordirectlyfrompaper

 # convert discrete variables to numeric
database$d15N <- as.numeric(as.character(database$d15N)) 
## Warning: NAs introduced by coercion
database$d13C <- as.numeric(as.character(database$d13C))
## Warning: NAs introduced by coercion
database$length <- as.numeric(as.character(database$length))  
## Warning: NAs introduced by coercion
database$lat <- as.numeric(as.character(database$lat))   
## Warning: NAs introduced by coercion
database$lon <- as.numeric(as.character(database$lon))  
## Warning: NAs introduced by coercion
database$TL_fishbase <- as.numeric(as.character(database$TL_fishbase))  
## Warning: NAs introduced by coercion
database$Authortrophiclevel <- as.numeric(as.character(database$Authortrophiclevel))  
## Warning: NAs introduced by coercion

Butterfish data?

database %>% filter(CommonName %in% c("Butterfish", "Butter_sh")) %>%
  ggplot() +
  geom_point(aes(Environment, d15N)) 

btf <- database %>% filter(CommonName %in% c("Butterfish", "Butter_sh"))
  
#colnames(database)
#sort(unique(database$CommonName))

Beginning to plot

gbgom <- database %>%
  filter(!is.na(jldCategory), GeneralLocation %in% c("Georges Bank", "Gulf of Maine")) %>%
  ggplot(aes(shape = ecology, color = jldCategory, fill = ecology)) +
  geom_point(aes(d13C, d15N), size = 8, stroke = 2) +
  ggtitle("Georges Bank and Gulf of Maine all species") +
  theme_bw() +
  theme(axis.text.y = element_text(size = rel(2.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(3), color = "black")) +
  theme(axis.text.x = element_text(size = rel(2.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(3), color = "black")) 

gbgom
## Warning: Removed 13 rows containing missing values (geom_point).

# 
# ## TO SEE WHAT THE "NOTHINGS" ARE HERE
# df <- gbgom <- database %>%
#   filter(!is.na(jldCategory), GeneralLocation %in% c("Georges Bank", "Gulf of Maine"), ecology == "-") 
# 
# #View(df)  

Exploratory: gelatinous zooplankton d15N and d13C, colored by latitude…

# sort(unique(database$jldCategory))

zoops <- database %>%
  filter(jldCategory == "Gelatinous zooplankton") %>%
  ggplot(aes(shape = Environment, color = GeneralLocation, fill = ecology)) +
  geom_point(aes(d13C, d15N), size = 8, stroke = 2) +
  ggtitle("Gelatinous zooplankton") +
  theme_bw() +
  theme(axis.text.y = element_text(size = rel(2.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(3), color = "black")) +
  theme(axis.text.x = element_text(size = rel(2.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(3), color = "black")) 

zoops
## Warning: Removed 10 rows containing missing values (geom_point).

whoah this is quite high:

Pleurobrachia pileus

from Das et al

# create dataframe of just Das et al data

df.Dasetal <- database %>%
  filter(References %in% c("Das et al 2003", "Das et al. (2003)", "Das et al., 2003", "Das et al., 2003; Dehn et al., 2007", "Das et al., 2003; Hoekstra et al., 2002", "Das et al., 2003; Loseto et al., 2008", "Das et al., 2003; Loseto et al., 2008; Sara et al., 2009; Lesage et al., 2001; Dehn et al., 2007", "Das et al., 2003; Sara et al., 2009")) 

#View(df.Dasetal)

# plot all Das et al data to see how these zooplankton compare to nekton

Dasetal <- database %>%
  filter(References %in% c("Das et al 2003", "Das et al. (2003)", "Das et al., 2003", "Das et al., 2003; Dehn et al., 2007", "Das et al., 2003; Hoekstra et al., 2002", "Das et al., 2003; Loseto et al., 2008", "Das et al., 2003; Loseto et al., 2008; Sara et al., 2009; Lesage et al., 2001; Dehn et al., 2007", "Das et al., 2003; Sara et al., 2009")) %>%
  ggplot(aes(shape = GeneralLocation, color = jldCategory)) +
  geom_point(aes(d13C, d15N), size = 8, stroke = 2, alpha = 0.7) +
  ggtitle("Das et al. 2003 -- what's going on with gelatinous zooplankton?") +
  theme_bw()

Dasetal

#ggplotly()

# create tally of Das et al data
  
tally.das <- database %>%
  filter(References %in% c("Das et al 2003", "Das et al. (2003)", "Das et al., 2003", "Das et al., 2003; Dehn et al., 2007", "Das et al., 2003; Hoekstra et al., 2002", "Das et al., 2003; Loseto et al., 2008", "Das et al., 2003; Loseto et al., 2008; Sara et al., 2009; Lesage et al., 2001; Dehn et al., 2007", "Das et al., 2003; Sara et al., 2009")) %>%
  group_by(GeneralLocation, Environment) %>%
  summarise(n = n())   #filter(year >= 1900)

#View(tally.das)  

tally.das
## Source: local data frame [0 x 3]
## Groups: GeneralLocation [?]
## 
## # ... with 3 variables: GeneralLocation <fctr>, Environment <fctr>,
## #   n <int>

Curious about Gadiformes and their distribution

plot of d15N vs d13C (gadiformes)

### plot of d15N vs d13C (gadiformes)

gads <- database %>%
  filter(Category.of.Interest == "Gadiformes") %>%
  ggplot(aes(shape = Environment, color = GeneralLocation)) + #fill = ecology
  geom_point(aes(d13C, d15N), size = 8, stroke = 2) +
  ggtitle("Gadiformes by general location") +
  theme_bw() +
  theme(axis.text.y = element_text(size = rel(2.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(3), color = "black")) +
  theme(axis.text.x = element_text(size = rel(2.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(3), color = "black")) 

gads
## Warning: Removed 41 rows containing missing values (geom_point).

# duplicates in the Carscallen or Badalamenti references? (gadiformes)
gadids <- database %>%
  filter(Category.of.Interest == "Gadiformes") %>%
  select(Category.of.Interest, d15N, d15N.sd., d13C, d13C.sd., CommonName, SpeciesName, GeneralLocation, References, lat, lon)

sort(gadids$d15N)
##   [1]  9.30  9.40  9.40  9.50  9.50  9.50  9.60  9.96 10.10 10.20 10.30
##  [12] 10.32 10.40 10.40 10.50 10.60 10.60 10.70 10.80 10.80 10.87 10.90
##  [23] 10.90 10.99 11.00 11.00 11.06 11.10 11.10 11.10 11.10 11.14 11.20
##  [34] 11.20 11.20 11.30 11.30 11.30 11.30 11.30 11.30 11.39 11.40 11.40
##  [45] 11.50 11.60 11.60 11.80 11.80 11.80 11.86 11.90 11.90 12.00 12.00
##  [56] 12.04 12.06 12.10 12.19 12.20 12.20 12.20 12.20 12.30 12.30 12.30
##  [67] 12.30 12.30 12.30 12.30 12.36 12.40 12.40 12.45 12.60 12.60 12.69
##  [78] 12.70 12.70 12.74 12.80 12.80 12.80 12.80 12.82 12.90 12.90 12.90
##  [89] 12.97 12.99 13.00 13.00 13.00 13.00 13.10 13.10 13.10 13.10 13.15
## [100] 13.20 13.23 13.30 13.30 13.30 13.30 13.36 13.40 13.40 13.40 13.40
## [111] 13.46 13.49 13.50 13.50 13.50 13.50 13.50 13.60 13.60 13.60 13.60
## [122] 13.60 13.60 13.60 13.64 13.70 13.70 13.70 13.70 13.70 13.70 13.70
## [133] 13.70 13.78 13.80 13.80 13.86 13.92 13.97 14.00 14.00 14.00 14.06
## [144] 14.10 14.15 14.18 14.20 14.20 14.20 14.20 14.21 14.21 14.21 14.27
## [155] 14.27 14.30 14.30 14.30 14.30 14.30 14.30 14.30 14.31 14.31 14.36
## [166] 14.39 14.40 14.40 14.40 14.41 14.50 14.59 14.60 14.60 14.60 14.62
## [177] 14.70 14.70 14.70 14.70 14.70 14.70 14.75 14.80 14.80 14.80 14.80
## [188] 14.80 14.80 14.80 14.80 14.81 14.87 14.90 14.92 15.00 15.00 15.00
## [199] 15.04 15.07 15.10 15.11 15.12 15.19 15.20 15.20 15.20 15.20 15.20
## [210] 15.20 15.20 15.25 15.30 15.43 15.50 15.50 15.50 15.60 15.60 15.60
## [221] 15.70 15.70 15.70 15.70 15.73 15.80 15.80 15.86 15.87 16.00 16.08
## [232] 16.10 16.20 16.40 16.40 16.50 16.70 16.80 16.90 17.03 17.10 17.20
## [243] 17.30 17.30 17.90 19.10 19.10 19.20 19.20
#View(gadids)

plot of length (mm) vs. d15N (gadiformes)

# in black to see accidental replicates
# sort(colnames(database))

database %>%
  filter(length %in% c(115:900), Category.of.Interest == "Gadiformes") %>%
  ggplot(aes(x = length, y = d15N)) +
  geom_point(aes(color = factor(lat), shape = GeneralLocation, fill = factor(lat)), stroke = 2, size = 4, alpha = 0.7) +
               scale_shape_manual(values=1:nlevels(database$GeneralLocation)) +
  theme_bw() +
  theme(legend.background = element_rect(fill = 'pink', size = 3)) + 
  ggtitle("Gadiformes: shape = location, fill = latitude, size = spp")


database %>%
  filter(length %in% c(115:900), Category.of.Interest == "Gadiformes") %>%
  ggplot(aes(x = length, y = d15N)) +
  geom_point(aes(fill = factor(lat)), stroke = 2, size = 4, alpha = 0.7) +
               scale_shape_manual(values=1:nlevels(database$GeneralLocation)) +
  theme_bw() +
  theme(legend.background = element_rect(fill = 'pink', size = 3)) + 
  ggtitle("Gadiformes - replicates appear dark black")


# in color, with species identified (gadiformes)

database %>%
  filter(length %in% c(115:900), 
         Category.of.Interest == "Gadiformes") %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(lat)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N of Gadiformes colored by latitude") +
  xlab("Length (mm)") +
  ylab("d15N (‰)") 

# in color, with species identified (gadiformes)

database %>%
  filter(length %in% c(115:900), 
         Category.of.Interest == "Gadiformes") %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by Gadiform species") +
  xlab("Length (mm)") +
  ylab("d15N (‰)") 

### STILL TO DO/modify:
### plot of d15N vs. latitude (gadiformes)
# colored by length? 

# Atlantic Ocean 

database %>%
  filter(length %in% c(115:900), 
         Category.of.Interest == "Gadiformes", 
         lon <= 30,
         lon >= -90) %>%
  ggplot() +
  geom_point(aes(x = lat, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by Gadiform species in the Atlantic Ocean") +
  xlab("Latitude") +
  ylab("d15N (‰)")

# All oceans 

database %>%
  filter(length %in% c(115:900), 
         Category.of.Interest == "Gadiformes") %>%
  ggplot() +
#   geom_point(aes(x = lon, y = lat, colour = factor(lon)), 
#              size = 5, 
#              alpha = 0.7) +
  geom_jitter(aes(x = lon, y = lat, colour = factor(SpeciesName)), 
              size = 5, 
              alpha = 0.7, 
              position = position_jitter(width = 7, height = 7)) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Lat vs. lon colored by Gadiform species in the all oceans") +
  ylab("Latitude") +
  xlab("Longitude") 

ggplotly()
###Length vs d15N across all oceans

unique(database$GeneralLocation)
##   [1] Hawaii                                  
##   [2] Labrador Shelf                          
##   [3] North Norway                            
##   [4] Antarctic                               
##   [5] Georges Bank                            
##   [6] Canadian Arctic                         
##   [7] Horn Island                             
##   [8] Narragansett Bay                        
##   [9] Mediterranean Sea                       
##  [10] Mad Island Marsh                        
##  [11] Northeast Pacific Ocean                 
##  [12] Baffin Bay                              
##  [13] Boston Harbor                           
##  [14] Acquatina Lagoon                        
##  [15] Sea of Japan                            
##  [16] Norway                                  
##  [17] Mediterannean Sea                       
##  [18] Gulf of St. Lawrence                    
##  [19] Arctic                                  
##  [20] Lancaster Sound                         
##  [21] Cananéia Lagoon Estuarine System        
##  [22] Hudson Bay                              
##  [23] Saglek Bay                              
##  [24] Caribbean Sea                           
##  [25] St. Kitts                               
##  [26] Isle of May                             
##  [27] Chesapeake Bay                          
##  [28] Cumberland Sound                        
##  [29] Stellwagen Bay                          
##  [30] West Greenland                          
##  [31] Barrow Strait                           
##  [32] North Sea                               
##  [33] Denmark                                 
##  [34] Massachusetts Bay                       
##  [35] North Sea                               
##  [36] Gulf of Alaska                          
##  [37] Greenland                               
##  [38] Southwest Greenland                     
##  [39] Spitsbergen                             
##  [40] Iceland                                 
##  [41] Barents Sea                             
##  [42] Prince William Sound                    
##  [43] Benguela                                
##  [44] California Current                      
##  [45] Pacific Ocean                           
##  [46] Newfoundland/Georges Band               
##  [47] Washington-Oregon                       
##  [48] East Japan                              
##  [49] Kuroshio-Oyashio                        
##  [50] Taiwan                                  
##  [51] Atlantic Ocean                          
##  [52] Bering Sea                              
##  [53] Gulf of Maine                           
##  [54] Mururoa Atoll, French Polynesia         
##  [55] Strangford Lough                        
##  [56] Massachusetts, U.S.A. (shelf)           
##  [57] Dipper Harbor                           
##  [58] Cutler                                  
##  [59] Scheldt Estuary                         
##  [60] Everywhere                              
##  [61] Baltic Sea                              
##  [62] Salish Sea                              
##  [63] Funk Island                             
##  [64] St. Kilda                               
##  [65] North Atlantic Ocean                    
##  [66] Svalbard                                
##  [67] East Greenland                          
##  [68] Caribbean                               
##  [69] St. Lawrence                            
##  [70] Australia                               
##  [71] Celtic Sea                              
##  [72] Northeast Greenland                     
##  [73] Gulf of Mexico                          
##  [74] Tasma Sea Abyssal basin                 
##  [75] Mid-Atlantic Ridge                      
##  [76] Eastern Baltic Sea                      
##  [77] Western Baltic Sea                      
##  [78] Arabian Sea                             
##  [79] Rhode Island and Block Island Sound     
##  [80] North Alaska                            
##  [81] Hutt River, New Zealand                 
##  [82] St. Marks                               
##  [83] Shelikof Strait                         
##  [84] Northern Norway                         
##  [85] Southwest Alaska                        
##  [86] South Alaska                            
##  [87] Rio Santa Cruz                          
##  [88] Northwest Miramichi River               
##  [89] European Lakes                          
##  [90] Quebec                                  
##  [91] Bering Strait                           
##  [92] Conception Bay                          
##  [93] Georgia, USA and KZN shelf, South Africa
##  [94] Cape Cod                                
##  [95] Davis Strait                            
##  [96] Joux (ch)                               
##  [97] Little River                            
##  [98] Snoqualmie River, Wash.                 
##  [99] Headwater lake of the Pointe Wolfe River
## [100] Chip River                              
## [101] Meade River                             
## [102] Martha's Vineyard                       
## [103] Kvichak River, Alaska                   
## [104] Northwest Atlantic                      
## [105] Bay of Biscay                           
## [106] Mid-Atlantic Bight                      
## [107] Grenada                                 
## [108] North Carolina Gulf Stream              
## [109] Jan Mayen                               
## [110] Vestjorden/Lofoten                      
## [111] North Carolina                          
## 111 Levels: Acquatina Lagoon Antarctic Arabian Sea ... Western Baltic Sea
## number of individuals per species in each environment
tally_species_env <- database %>%
  group_by(Environment, SpeciesName) %>%
  summarise(n = n()) 

## number of species per environment
tally_species_env_tally <- tally_species_env %>%
  group_by(Environment) %>%
  summarise(NumberOfSp = n()) 

## plot
tally_species_env_tally %>% filter(Environment != "-", Environment != "") %>%
  ggplot(aes(Environment, NumberOfSp)) + 
  geom_point(size = 5)+ 
  labs(x = "", y = "Count of species", title = "# of species per environment")

## number of individuals per species in each part of the world
tally_species_loc <- database %>%
  group_by(GeneralLocation, SpeciesName) %>%
  summarise(n = n()) 

## number of species per environment
tally_species_loc_tally <- tally_species_loc %>%
  group_by(GeneralLocation) %>%
  summarise(NumberOfLoc = n()) 

## plot
tally_species_loc_tally %>% filter(GeneralLocation != "-", GeneralLocation != "") %>%
  ggplot(aes(GeneralLocation, NumberOfLoc)) + 
  geom_point(size = 5) +
  geom_text(aes(label=NumberOfLoc), hjust=-0.5, vjust=-0.5) +
  labs(x = "", y = "Count of species", title = "# of species per location") +
  theme(axis.text.x  = element_text(angle=90, vjust=0.5, size=12))

# Atlantic
database %>%
  filter(length %in% c(115:900), 
         #Category.of.Interest == "Gadiformes", 
         lon <= 30,
         lon >= -90) %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  #stat_smooth(method="lm", x=length, y=d15N) + # Needs x and y aesthetics in the ggplot() thing
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by species in the Atlantic Ocean") +
  xlab("Length") +
  ylab("d15N (‰)")

databasestat <- database %>%
  filter(length %in% c(115:900), 
         #Category.of.Interest == "Gadiformes", 
         lon <= 30,
         lon >= -90)
x <- databasestat$length
y <- databasestat$d15N

cor.test(y,x)
## 
##  Pearson's product-moment correlation
## 
## data:  y and x
## t = 4.5801, df = 159, p-value = 9.333e-06
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.1971389 0.4711961
## sample estimates:
##       cor 
## 0.3414035
lm <- lm(y~x)
lm
## 
## Call:
## lm(formula = y ~ x)
## 
## Coefficients:
## (Intercept)            x  
##   11.908962     0.003755
summary(lm)
## 
## Call:
## lm(formula = y ~ x)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3.1835 -1.6497 -0.0614  1.1802  6.2640 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 1.191e+01  2.906e-01   40.99  < 2e-16 ***
## x           3.755e-03  8.199e-04    4.58 9.33e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.893 on 159 degrees of freedom
## Multiple R-squared:  0.1166, Adjusted R-squared:  0.111 
## F-statistic: 20.98 on 1 and 159 DF,  p-value: 9.333e-06
# Pacific
database %>%
  filter(length %in% c(115:900), 
         #Category.of.Interest == "Gadiformes", 
         lon <= -75 || lon >= 120) %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by species in the Pacific Ocean") +
  xlab("Length") +
  ylab("d15N (‰)")

# Southern
database %>%
  filter(length %in% c(115:900), 
         #Category.of.Interest == "Gadiformes", 
         lat <= -50) %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by species in the Southern Ocean") +
  xlab("Length") +
  ylab("d15N (‰)") 

# Europe
database %>%
  filter(length %in% c(115:900), 
         #Category.of.Interest == "Gadiformes", 
         lat >= 30,
         lon <= 45,
         lon >= -25) %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by species in Europe") +
  xlab("Length") +
  ylab("d15N (‰)") 

# Indian
database %>%
  filter(length %in% c(115:900), 
         #Category.of.Interest == "Gadiformes", 
         lat <= 30,
         lat >= -45,
         lon <= 120,
         lon >= 30) %>%
  ggplot() +
  geom_point(aes(x = length, y = d15N, colour = factor(SpeciesName)), 
             size = 5, 
             alpha = 0.7) +
  theme_bw() +
  scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
  theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
  theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
  theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
  theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
  ggtitle("Length vs. d15N colored by species in the Indian Ocean") +
  xlab("Length") +
  ylab("d15N (‰)") 

## Not working

# # Data per region
# database %>%
# filter(length %in% c(115:900),
#         !is.na(SpeciesName)
#         #Category.of.Interest == "Gadiformes",
#         ) %>%
#    ggplot(aes(y=SpeciesName)) +
#   facet_wrap(~Environment)
#    theme_bw() +
#    scale_fill_continuous(guide = guide_legend(title = "Species Name")) +
#  #  scale_x_continuous(breaks = seq(100, 2000, by = 100)) + 
#    theme(axis.text.y = element_text(size = rel(1.5), color = "black")) +
#    theme(axis.title.y = element_text(size = rel(1.75), color = "black")) +
#    theme(axis.text.x = element_text(size = rel(1.5), color = "black")) + 
#    theme(axis.title.x = element_text(size = rel(1.75), color = "black")) +
#    ggtitle("Length vs. d15N colored by species in the Indian Ocean") +
#    xlab("Length") +
#    ylab("d15N (‰)") 

#summarise_by, group_by
#View(database)

d <- database %>%
  filter(jldCategory %in% c(1),
         !is.na(d15N)) %>%,
        
  inner_join(Station %>%
               filter(gear.id %in% c(77,78),
                      month %in% c(9:11),
                      year %in% c(2013:2014),
                      lat >= 65.5,
                      lon <= -20,
                      lon >= -26) %>%
               select(synis.id, year, month, square, gear.id,
                      sample.class, lon, lat, depth, botnhiti)) %>%
  rename(temperature = botnhiti) %>%
  mutate(sel.length = ifelse(length %in% 65:74,TRUE, FALSE))