final_project_dataset_vetting_sds300

Author

Leah Harries + Lorelei Ing + Destiny Cecchi + Danielle Weiss

 getwd() 
[1] "C:/Users/Danie/Documents/SDS300_R_WORK_DW/final_proj"
 library(ggplot2)
Warning: package 'ggplot2' was built under R version 4.3.2
 library(tidyverse)
Warning: package 'tidyverse' was built under R version 4.3.2
Warning: package 'tidyr' was built under R version 4.3.2
Warning: package 'readr' was built under R version 4.3.2
Warning: package 'purrr' was built under R version 4.3.2
Warning: package 'dplyr' was built under R version 4.3.2
Warning: package 'forcats' was built under R version 4.3.2
Warning: package 'lubridate' was built under R version 4.3.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.5
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ lubridate 1.9.3     ✔ tibble    3.2.1
✔ purrr     1.0.2     ✔ tidyr     1.3.0
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
 library(dplyr)
Final Project Part 4: 
- datasets
- methods (where did data come from + how was it collected + sources)
- show it contains data to test the research questions
- how to test for the research questions
Data set vetting answers:

Research questions + goals: 
- How does ocean chemistry affect hard coral cover in the Florida keys? 
  - Analyze the relationship between ocean chemistry (pH, temperature, aragonite saturation) and the abundance of hard coral cover in 3 regions of Florida Keys (Florida Keys, Tortugas, SEFCRI)
- How does hard coral cover vary over time within the Florida Keys?
  - Compare hard coral cover over time in Florida Keys (not split into region)
- How does hard coral cover vary over time in each region of interest?
  - Compare hard coral cover over time within each region and in comparison to each region
- How does hard coral cover of specific species change over time within each region and in comparison to each region?
  - Compare hard coral cover of species observed over time in each region  
- What are the trends in carbonate chemistry within each region and in comparison to each region?
  - Compare carbonate chemistry variables over time  in each region 

Datasets:
- Our benthic coral data and carbonate chemistry has the variables we want to analyze (all between 2016-2022)
- Benthic coral data - focused on hard corals for now
  - regions (FLK (florida keys) DRT (tortugas) and SEFCRI (south east florida coral reef initiative))
    - observations: DRT (1264) FLK (820) SEFCRI (276) 
  - species (COVER_CAT_NAME)
    - filtered down to hard coral species with n>20 (18 species)
  - hard coral cover percentage (HARDBOTTOM_P)
- Carbonate chemistry data - focused on pH + Temp + Aragonite saturation
  - FLK (florida keys) DRT (tortugas) and SEFCRI (south east florida coral reef initiative)
  - observations: DRT (158) FLK (2222) SEFCRI (48) 
  - filtered down to: time, latitude, longitude, Region, Year, DIC, pH_measured, pH_calculated, pCO2, Aragonite_Sat, Temperature_C

Visualizations: 
- Map of ΩAr, temperature, and pH across Florida Keys (start with ΩAr and maybe the other two)
- Changes in % hard coral cover over time at each region and overall
- Changes in aragonite saturation, temperature, and pH against coral cover 

Statistical Analysis: analyze BOTH datasets
- Check variability
- Model selection  
- Different sites species diversity or coral cover over time (ANOVA)
- Different sites coral cover over time looking at different chemistry variables (ANOVA)
- Compare carbonate chemistry with (mixed modeling)
- Compare coral and algal cover with (mixed modeling)
- 95% CI for different mixed models  
- PCoA?

Dataset information:
We are using two data sets: CRCP carbonate chemistry and CRCP Benthic cover and
both of these data are sourced from NOAA (National Oceanic and Atmospheric
Administration). The carbonate chemistry data set contains different
measurements taken at long-term monitoring sites in the Atlantic by NOAA NCRMP
(National Coral Reef Monitoring Program) and includes variables like dissolved
inorganic carbon, total alkalinity, and other carbonate chemistry related
measurements. Monitoring sites included locations in the US Virgin Islands (St.
Croix, St. John, and St. Thomas), the Florida Keys, Puerto Rico, Flower Garden
Banks (Texas),  and Dry Tortugas (Florida). Water samples for carbonate
chemistry analysis were collected in two ways: active sampling done by SCUBA
divers during research excursions at monitoring sites and using sub automatic
water samplers, which took samples at 15 meters deep. The samples were brought
back to the lab and analyzed to get TA and DIC, which is combined with
temperature, depth, and salinity to inform other important carbonate chemistry
variables (e.g. pH, aragonite saturation, pCO2– all of which are also reported
in the data set). 
The benthic monitoring data also comes out of surveys done by NCRMP to assess
reef health throughout Florida and data is collected in two ways: Benthic
Assessment and the Coral Demographic. The Benthic Assessment gives an estimate
of cover types that are considered ecologically important, which contains
groups like macroalgae, crustose coralline algae, san, coral, etc.,. Data from
these surveys are collected by divers at randomly selected transects at each
site and surveys were collected at 30 meters deep. The goal of which is to
understand percent cover of benthic species, rugosity at each location, assess
ecologically important invertebrates (e.g. urchins, lobster, queen conch
etc.,), and assess presence and absence of ESA listed corals. For the Coral
Demographic method, surveys were measured by 10m x 1m belt transects that were
placed at random reef habitats. These surveys report information on species
such as density, size, abundance, diversity, and condition (e.g. live vs dead,
bleaching, diseased etc.,). 
# filter data 

# coral florida data
coral <- read.csv("C:/Users/Danie/Documents/SDS300_R_WORK_DW/final_proj/benthic_coral_florida.csv") |>
  mutate(REGION = recode(REGION, `Tortugas` = "DRT"))

# view data
head(coral) 
                  time      latitude    longitude REGION PRIMARY_SAMPLE_UNIT
1                  UTC degrees_north degrees_east                         NA
2 2016-06-22T00:00:00Z      24.46499     -81.9823    FLK                1702
3 2016-06-22T00:00:00Z      24.46499     -81.9823    FLK                1702
4 2016-06-22T00:00:00Z      24.46499     -81.9823    FLK                1702
5 2016-06-22T00:00:00Z      24.46499     -81.9823    FLK                1702
6 2016-06-22T00:00:00Z      24.46499     -81.9823    FLK                1702
  STATION_NR YEAR MONTH DAY             Date_UTC HABITAT_CD
1         NA   NA    NA  NA                  UTC           
2          1 2016     6  22 2016-06-22T00:00:00Z    CONT_LR
3          1 2016     6  22 2016-06-22T00:00:00Z    CONT_LR
4          1 2016     6  22 2016-06-22T00:00:00Z    CONT_LR
5          1 2016     6  22 2016-06-22T00:00:00Z    CONT_LR
6          1 2016     6  22 2016-06-22T00:00:00Z    CONT_LR
                                             HABITAT_TYPE STRAT
1                                                              
2 Contiguous reef - non-spur-groove - low vertical relief  MCPR
3 Contiguous reef - non-spur-groove - low vertical relief  MCPR
4 Contiguous reef - non-spur-groove - low vertical relief  MCPR
5 Contiguous reef - non-spur-groove - low vertical relief  MCPR
6 Contiguous reef - non-spur-groove - low vertical relief  MCPR
             Description RUGOSITY_CD   WTD_RUG MAPGRID_NR SUB_REGION_NAME
1                                 NA        NA         NA                
2 Mid Channel Patch Reef          NA 0.2966667     888235      Lower Keys
3 Mid Channel Patch Reef          NA 0.2966667     888235      Lower Keys
4 Mid Channel Patch Reef          NA 0.2966667     888235      Lower Keys
5 Mid Channel Patch Reef          NA 0.2966667     888235      Lower Keys
6 Mid Channel Patch Reef          NA 0.2966667     888235      Lower Keys
  SUB_REGION_NR   ZONE_NAME ZONE_NR    MPA_NAME MPA_NR ADMIN PROT DEPTH_STRAT
1            NA                  NA                 NA    NA   NA            
2             8 Mid Channel       2 Unprotected      0    NA    0        <NA>
3             8 Mid Channel       2 Unprotected      0    NA    0        <NA>
4             8 Mid Channel       2 Unprotected      0    NA    0        <NA>
5             8 Mid Channel       2 Unprotected      0    NA    0        <NA>
6             8 Mid Channel       2 Unprotected      0    NA    0        <NA>
    MIN_DEPTH   MAX_DEPTH METERS_COMPLETED COVER_CAT_CD       COVER_CAT_NAME
1           m           m                m                                  
2 7.010399776 7.315199766               15     EUS FAST  Eusmilia fastigiata
3 7.010399776 7.315199766               15     GOR ENCR Encrusting gorgonian
4 7.010399776 7.315199766               15     GOR GORG           Gorgonians
5 7.010399776 7.315199766               15     MEA MEAN Meandrina meandrites
6 7.010399776 7.315199766               15     ORB FAVE  Orbicella faveolata
  HARDBOTTOM_P SOFTBOTTOM_P RUBBLE_P                           accession_url
1      percent      percent  percent                                        
2            1            0        0 https://accession.nodc.noaa.gov/0169401
3            2            0        0 https://accession.nodc.noaa.gov/0169401
4           13            0        0 https://accession.nodc.noaa.gov/0169401
5            1            0        0 https://accession.nodc.noaa.gov/0169401
6            4            0        0 https://accession.nodc.noaa.gov/0169401
summary(coral)
     time             latitude          longitude            REGION         
 Length:13602       Length:13602       Length:13602       Length:13602      
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
 PRIMARY_SAMPLE_UNIT   STATION_NR         YEAR          MONTH       
 Min.   :1004        Min.   :1.000   Min.   :2016   Min.   : 1.000  
 1st Qu.:1702        1st Qu.:1.000   1st Qu.:2016   1st Qu.: 8.000  
 Median :2308        Median :1.000   Median :2018   Median : 8.000  
 Mean   :2784        Mean   :1.048   Mean   :2019   Mean   : 8.189  
 3rd Qu.:3114        3rd Qu.:1.000   3rd Qu.:2022   3rd Qu.: 9.000  
 Max.   :9999        Max.   :2.000   Max.   :2022   Max.   :12.000  
 NA's   :1           NA's   :1       NA's   :1      NA's   :1       
      DAY          Date_UTC          HABITAT_CD        HABITAT_TYPE      
 Min.   : 1.00   Length:13602       Length:13602       Length:13602      
 1st Qu.:11.00   Class :character   Class :character   Class :character  
 Median :17.00   Mode  :character   Mode  :character   Mode  :character  
 Mean   :16.75                                                           
 3rd Qu.:23.00                                                           
 Max.   :31.00                                                           
 NA's   :1                                                               
    STRAT           Description         RUGOSITY_CD       WTD_RUG     
 Length:13602       Length:13602       Min.   :0.000   Min.   :0.150  
 Class :character   Class :character   1st Qu.:0.000   1st Qu.:0.270  
 Mode  :character   Mode  :character   Median :1.000   Median :0.437  
                                       Mean   :0.601   Mean   :0.562  
                                       3rd Qu.:1.000   3rd Qu.:0.720  
                                       Max.   :2.000   Max.   :2.000  
                                       NA's   :10142   NA's   :6556   
   MAPGRID_NR      SUB_REGION_NAME    SUB_REGION_NR     ZONE_NAME        
 Min.   :  18460   Length:13602       Min.   : 3.000   Length:13602      
 1st Qu.: 571446   Class :character   1st Qu.: 4.000   Class :character  
 Median :1345270   Mode  :character   Median : 8.000   Mode  :character  
 Mean   :1383450                      Mean   : 8.125                     
 3rd Qu.:1735944                      3rd Qu.:13.000                     
 Max.   :4155843                      Max.   :17.000                     
 NA's   :1                            NA's   :1                          
    ZONE_NR        MPA_NAME             MPA_NR        ADMIN        
 Min.   :0.000   Length:13602       Min.   : 0.000   Mode:logical  
 1st Qu.:4.000   Class :character   1st Qu.: 0.000   NA's:13602    
 Median :4.000   Mode  :character   Median : 0.000                 
 Mean   :4.395                      Mean   : 7.294                 
 3rd Qu.:6.000                      3rd Qu.:24.000                 
 Max.   :7.000                      Max.   :28.000                 
 NA's   :3461                       NA's   :1                      
      PROT      DEPTH_STRAT         MIN_DEPTH          MAX_DEPTH        
 Min.   :0.00   Length:13602       Length:13602       Length:13602      
 1st Qu.:0.00   Class :character   Class :character   Class :character  
 Median :1.00   Mode  :character   Mode  :character   Mode  :character  
 Mean   :0.91                                                           
 3rd Qu.:2.00                                                           
 Max.   :2.00                                                           
 NA's   :1                                                              
 METERS_COMPLETED   COVER_CAT_CD       COVER_CAT_NAME     HARDBOTTOM_P      
 Length:13602       Length:13602       Length:13602       Length:13602      
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
 SOFTBOTTOM_P         RUBBLE_P         accession_url     
 Length:13602       Length:13602       Length:13602      
 Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character  
                                                         
                                                         
                                                         
                                                         
# species with >20 data points 
count_species <- coral |>
  group_by(COVER_CAT_NAME)|>
  summarise(n = n(),
            count = n())|>
  arrange(desc(count))
count_species
# A tibble: 73 × 3
   COVER_CAT_NAME               n count
   <chr>                    <int> <int>
 1 Turf Algae with Sediment  1183  1183
 2 Porifera spp              1126  1126
 3 Bare Substrate            1042  1042
 4 Gorgonians                 993   993
 5 Dictyota spp               965   965
 6 MacroOtherFleshy           802   802
 7 Encrusting gorgonian       707   707
 8 Rhodophyta cru. spp        639   639
 9 Siderastrea siderea        539   539
10 Halimeda spp               511   511
# ℹ 63 more rows
coral1 <- coral |>
  group_by(COVER_CAT_NAME)|>
  filter(n()>20) |>
  filter(!is.na(COVER_CAT_NAME))
head(coral1)
# A tibble: 6 × 35
# Groups:   COVER_CAT_NAME [6]
  time      latitude longitude REGION PRIMARY_SAMPLE_UNIT STATION_NR  YEAR MONTH
  <chr>     <chr>    <chr>     <chr>                <int>      <int> <int> <int>
1 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
2 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
3 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
4 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
5 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
6 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
# ℹ 27 more variables: DAY <int>, Date_UTC <chr>, HABITAT_CD <chr>,
#   HABITAT_TYPE <chr>, STRAT <chr>, Description <chr>, RUGOSITY_CD <int>,
#   WTD_RUG <dbl>, MAPGRID_NR <int>, SUB_REGION_NAME <chr>,
#   SUB_REGION_NR <int>, ZONE_NAME <chr>, ZONE_NR <dbl>, MPA_NAME <chr>,
#   MPA_NR <int>, ADMIN <lgl>, PROT <int>, DEPTH_STRAT <chr>, MIN_DEPTH <chr>,
#   MAX_DEPTH <chr>, METERS_COMPLETED <chr>, COVER_CAT_CD <chr>,
#   COVER_CAT_NAME <chr>, HARDBOTTOM_P <chr>, SOFTBOTTOM_P <chr>, …
# filter down to only hard corals with >20 data points (18 hard coral species)
coral1 <- coral1 |>
  filter(COVER_CAT_NAME %in% c("Acropora cervicornis", "Agaricia agaricites", "Colpophyllia natans", "Dichocoenia stokesii", "Diploria labyrinthiformis", "Madracis decactis", "Meandrina meandrites", "Montastraea cavernosa", "Orbicella annularis", "Orbicella faveolata", "Orbicella franksi", "Porites astreoides", "Porites porites", "Siderastrea radians ", "Siderastrea siderea", "Solenastrea bournoni", "Stephanocoenia intersepta", "Pseudodiploria strigosa"))

# view data
head(coral1)
# A tibble: 6 × 35
# Groups:   COVER_CAT_NAME [6]
  time      latitude longitude REGION PRIMARY_SAMPLE_UNIT STATION_NR  YEAR MONTH
  <chr>     <chr>    <chr>     <chr>                <int>      <int> <int> <int>
1 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
2 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
3 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
4 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
5 2016-06-… 24.46499 -81.9823  FLK                   1702          1  2016     6
6 2016-06-… 24.46302 -81.7548  FLK                   1741          1  2016     6
# ℹ 27 more variables: DAY <int>, Date_UTC <chr>, HABITAT_CD <chr>,
#   HABITAT_TYPE <chr>, STRAT <chr>, Description <chr>, RUGOSITY_CD <int>,
#   WTD_RUG <dbl>, MAPGRID_NR <int>, SUB_REGION_NAME <chr>,
#   SUB_REGION_NR <int>, ZONE_NAME <chr>, ZONE_NR <dbl>, MPA_NAME <chr>,
#   MPA_NR <int>, ADMIN <lgl>, PROT <int>, DEPTH_STRAT <chr>, MIN_DEPTH <chr>,
#   MAX_DEPTH <chr>, METERS_COMPLETED <chr>, COVER_CAT_CD <chr>,
#   COVER_CAT_NAME <chr>, HARDBOTTOM_P <chr>, SOFTBOTTOM_P <chr>, …
# 2360 observations for all hard coral species included
# locations = FLK (florida keys) DRT (tortugas) and SEFCRI (south east florida coral reef initiative)
count_location <- coral1 |>
  group_by(REGION) |>
  summarise(count = n())
count_location
# A tibble: 3 × 2
  REGION count
  <chr>  <int>
1 DRT     1264
2 FLK      820
3 SEFCRI   276
# observations: DRT (1264) FLK (820) SEFCRI (276) 
Hard corals n > 20: 
Acropora cervicornis
Agaricia agaricites
Colpophyllia natans
Dichocoenia stokesii
Diploria labyrinthiformis
Madracis decactis
Meandrina meandrites
Montastraea cavernosa
Orbicella annularis
Orbicella faveolata
Orbicella franksi
Porites astreoides
Porites porites
Siderastrea radians
Siderastrea siderea
Solenastrea bournoni
Stephanocoenia intersepta
Pseudodiploria strigosa
# carbonate chemistry data
# create location abbreviations + filter data by region
carb1 <- read.csv("C:/Users/Danie/Documents/SDS300_R_WORK_DW/final_proj/carbonate_chem_atlantic.csv") |>
  mutate(Region = recode(Region, `FL` = "FLK", `DRTO` = "DRT", `DT` = "DRT")) |>
  filter(Region %in% c("FLK", "DRT", "SEFCRI"))

# view data
head(carb1)
                  time    latitude    longitude            CTDID Region Year
1 2017-01-05T13:40:00Z 24.90518333     -80.6266 CalVal_Jan2017_1    FLK 2017
2 2017-01-05T13:55:00Z 24.89826667 -80.61738333 CalVal_Jan2017_2    FLK 2017
3 2017-01-05T14:05:00Z 24.89818333 -80.61606667 CalVal_Jan2017_3    FLK 2017
4 2017-01-05T14:17:00Z     24.8977 -80.61816667 CalVal_Jan2017_4    FLK 2017
5 2017-01-05T14:17:00Z     24.8977 -80.61816667 CalVal_Jan2017_5    FLK 2017
6 2017-01-05T14:27:00Z 24.89663333     -80.6153 CalVal_Jan2017_6    FLK 2017
  Mission Location  UTCDate UTCTime             Date_UTC Sample_Depth_m
1  CalVal      FLK 1/5/2017   13:40 2017-01-05T13:40:00Z              0
2  CalVal      FLK 1/5/2017   13:55 2017-01-05T13:55:00Z              0
3  CalVal      FLK 1/5/2017   14:05 2017-01-05T14:05:00Z              0
4  CalVal      FLK 1/5/2017   14:17 2017-01-05T14:17:00Z              0
5  CalVal      FLK 1/5/2017   14:17 2017-01-05T14:17:00Z              0
6  CalVal      FLK 1/5/2017   14:27 2017-01-05T14:27:00Z              0
          DIC          TA pH_measured pH_calculated        pCO2 Aragonite_Sat
1 2123.014035 2411.608632    7.994548           NaN 475.2770518      3.268880
2 2140.529652 2420.513021    7.978449           NaN 498.9336095      3.187039
3 2126.982858 2410.647741    7.986262           NaN 486.1758318      3.218789
4 2145.016273  2422.22993    7.972165           NaN 508.0844039      3.162853
5 2143.278035 2420.021861    7.971244           NaN 508.7680168      3.155604
6 2119.951218 2421.537582    8.014780           NaN 450.9955019      3.405095
  Calcdsalinity Salinity_Bottle Conductivity_Sm Salinity_CTD Temperature_C
1           NaN     36.56578472             NaN         34.4          24.7
2           NaN     36.57792046             NaN         34.5          24.7
3           NaN     36.56840415             NaN         34.6          24.7
4           NaN     36.56089414             NaN         34.6          24.8
5           NaN     36.59590795             NaN         34.6          24.8
6           NaN     36.57137189             NaN         34.7          24.7
  Pressure_db Density_Sigmat       SiteID Survey_design Sample_frequency Notes
1         NaN            NaN   Transect 1     Permanent           Single      
2         NaN            NaN     CalVal N     Permanent           Single      
3         NaN            NaN      ADCP NE     Permanent           Single      
4         NaN            NaN Map CO2 Buoy     Permanent           Single      
5         NaN            NaN Map CO2 Buoy     Permanent           Single      
6         NaN            NaN    CalVal SE     Permanent           Single      
                            accession_url
1 https://accession.nodc.noaa.gov/0162411
2 https://accession.nodc.noaa.gov/0162411
3 https://accession.nodc.noaa.gov/0162411
4 https://accession.nodc.noaa.gov/0162411
5 https://accession.nodc.noaa.gov/0162411
6 https://accession.nodc.noaa.gov/0162411
summary(carb1)
     time             latitude          longitude            CTDID          
 Length:2428        Length:2428        Length:2428        Length:2428       
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
    Region               Year        Mission            Location        
 Length:2428        Min.   :2015   Length:2428        Length:2428       
 Class :character   1st Qu.:2017   Class :character   Class :character  
 Mode  :character   Median :2018   Mode  :character   Mode  :character  
                    Mean   :2019                                        
                    3rd Qu.:2020                                        
                    Max.   :2022                                        
                                                                        
   UTCDate            UTCTime            Date_UTC         Sample_Depth_m    
 Length:2428        Length:2428        Length:2428        Length:2428       
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
     DIC                 TA             pH_measured    pH_calculated  
 Length:2428        Length:2428        Min.   :7.319   Min.   :7.670  
 Class :character   Class :character   1st Qu.:8.002   1st Qu.:7.970  
 Mode  :character   Mode  :character   Median :8.038   Median :8.009  
                                       Mean   :8.032   Mean   :8.003  
                                       3rd Qu.:8.070   3rd Qu.:8.045  
                                       Max.   :8.372   Max.   :8.203  
                                       NA's   :43      NA's   :1591   
     pCO2           Aragonite_Sat   Calcdsalinity      Salinity_Bottle   
 Length:2428        Min.   :1.025   Length:2428        Length:2428       
 Class :character   1st Qu.:3.473   Class :character   Class :character  
 Mode  :character   Median :3.720   Mode  :character   Mode  :character  
                    Mean   :3.687                                        
                    3rd Qu.:3.930                                        
                    Max.   :5.342                                        
                    NA's   :28                                           
 Conductivity_Sm    Salinity_CTD       Temperature_C      Pressure_db       
 Length:2428        Length:2428        Length:2428        Length:2428       
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
 Density_Sigmat        SiteID          Survey_design      Sample_frequency  
 Length:2428        Length:2428        Length:2428        Length:2428       
 Class :character   Class :character   Class :character   Class :character  
 Mode  :character   Mode  :character   Mode  :character   Mode  :character  
                                                                            
                                                                            
                                                                            
                                                                            
    Notes           accession_url     
 Length:2428        Length:2428       
 Class :character   Class :character  
 Mode  :character   Mode  :character  
                                      
                                      
                                      
                                      
# select columns
  carb1 <- carb1 |>
  select(time, latitude, longitude, Region, Year, DIC, pH_measured, pH_calculated, pCO2, Aragonite_Sat, Temperature_C)
head(carb1)
                  time    latitude    longitude Region Year         DIC
1 2017-01-05T13:40:00Z 24.90518333     -80.6266    FLK 2017 2123.014035
2 2017-01-05T13:55:00Z 24.89826667 -80.61738333    FLK 2017 2140.529652
3 2017-01-05T14:05:00Z 24.89818333 -80.61606667    FLK 2017 2126.982858
4 2017-01-05T14:17:00Z     24.8977 -80.61816667    FLK 2017 2145.016273
5 2017-01-05T14:17:00Z     24.8977 -80.61816667    FLK 2017 2143.278035
6 2017-01-05T14:27:00Z 24.89663333     -80.6153    FLK 2017 2119.951218
  pH_measured pH_calculated        pCO2 Aragonite_Sat Temperature_C
1    7.994548           NaN 475.2770518      3.268880          24.7
2    7.978449           NaN 498.9336095      3.187039          24.7
3    7.986262           NaN 486.1758318      3.218789          24.7
4    7.972165           NaN 508.0844039      3.162853          24.8
5    7.971244           NaN 508.7680168      3.155604          24.8
6    8.014780           NaN 450.9955019      3.405095          24.7
# factor -> numeric
carb1$Temperature_C = as.numeric(carb1$Temperature_C)

# summary stats looking at data in each region
ds_chem <- carb1 |>
  group_by(Region, na.rm = TRUE) |>
  summarise(n = n(),
            mean_PH = mean(pH_measured, na.rm=TRUE),
            mean_Temp = mean(Temperature_C, na.rm=TRUE),
            mean_AS = mean(Aragonite_Sat, na.rm=TRUE))
`summarise()` has grouped output by 'Region'. You can override using the
`.groups` argument.
head(ds_chem)
# A tibble: 3 × 6
# Groups:   Region [3]
  Region na.rm     n mean_PH mean_Temp mean_AS
  <chr>  <lgl> <int>   <dbl>     <dbl>   <dbl>
1 DRT    TRUE    158    8.01      29.0    3.76
2 FLK    TRUE   2222    8.03      27.3    3.68
3 SEFCRI TRUE     48    8.02      28.5    3.83
# 2016-2022
# summary stats looking at data in each year + region
ds2_chem <- carb1 |>
  group_by(Year, Region,na.rm = TRUE) |>
  summarise(n = n(),
            mean_PH = mean(pH_measured, na.rm=TRUE),
            mean_Temp = mean(Temperature_C, na.rm=TRUE),
            mean_AS = mean(Aragonite_Sat, na.rm=TRUE))
`summarise()` has grouped output by 'Year', 'Region'. You can override using
the `.groups` argument.
head(ds2_chem)
# A tibble: 6 × 7
# Groups:   Year, Region [6]
   Year Region na.rm     n mean_PH mean_Temp mean_AS
  <int> <chr>  <lgl> <int>   <dbl>     <dbl>   <dbl>
1  2015 FLK    TRUE     17    8.02      25.8    3.37
2  2016 DRT    TRUE     43    8.03      27.1    3.72
3  2016 FLK    TRUE    411    8.04      27.1    3.73
4  2017 FLK    TRUE    388    8.03      27.2    3.70
5  2018 DRT    TRUE     68    8.00      29.5    3.85
6  2018 FLK    TRUE    353    8.05      27.5    3.84