Last updated: 2020-07-24

Checks: 7 0

Knit directory: Cant_eMLR/

This reproducible R Markdown analysis was created with workflowr (version 1.6.2). The Checks tab describes the reproducibility checks that were applied when the results were created. The Past versions tab lists the development history.


Great! Since the R Markdown file has been committed to the Git repository, you know the exact version of the code that produced these results.

Great job! The global environment was empty. Objects defined in the global environment can affect the analysis in your R Markdown file in unknown ways. For reproduciblity it’s best to always run the code in an empty environment.

The command set.seed(20200707) was run prior to running the code in the R Markdown file. Setting a seed ensures that any results that rely on randomness, e.g. subsampling or permutations, are reproducible.

Great job! Recording the operating system, R version, and package versions is critical for reproducibility.

Nice! There were no cached chunks for this analysis, so you can be confident that you successfully produced the results during this run.

Great job! Using relative paths to the files within your workflowr project makes it easier to run your code on other machines.

Great! You are using Git for version control. Tracking code development and connecting the code version to the results is critical for reproducibility.

The results in this page were generated with repository version 12f9ef2. See the Past versions tab to see a history of the changes made to the R Markdown and HTML files.

Note that you need to be careful to ensure that all relevant files for the analysis have been committed to Git prior to generating the results (you can use wflow_publish or wflow_git_commit). workflowr only checks the R Markdown file, but you know if there are other scripts or data files that it depends on. Below is the status of the Git repository when the results were generated:


Ignored files:
    Ignored:    .Rproj.user/
    Ignored:    data/GLODAPv2_2016b_MappedClimatologies/
    Ignored:    data/GLODAPv2_2020/
    Ignored:    data/World_Ocean_Atlas_2018/
    Ignored:    data/pCO2_atmosphere/
    Ignored:    dump/
    Ignored:    output/figure/

Note that any generated files, e.g. HTML, png, CSS, etc., are not included in this status report because it is ok for generated content to have uncommitted changes.


These are the previous versions of the repository in which changes were made to the R Markdown (analysis/eMLR.Rmd) and HTML (docs/eMLR.html) files. If you’ve configured a remote Git repository (see ?wflow_git_remote), click on the hyperlinks in the table below to view the files as they were in that past version.

File Version Author Date Message
Rmd 12f9ef2 jens-daniel-mueller 2020-07-24 started neutral density calculation
html 2e08795 jens-daniel-mueller 2020-07-24 Build site.
html 61a1a48 jens-daniel-mueller 2020-07-24 Build site.
Rmd 864a6e3 jens-daniel-mueller 2020-07-24 merged predictor data sets
html 7f51d57 jens-daniel-mueller 2020-07-24 Build site.
Rmd 4a8deb2 jens-daniel-mueller 2020-07-24 corrected false to FALSE
html 2df2065 jens-daniel-mueller 2020-07-23 Build site.
Rmd fa350cf jens-daniel-mueller 2020-07-23 predictor correlation plots, bin2d map plots
html 9d1d67d jens-daniel-mueller 2020-07-23 Build site.
Rmd 3b6658b jens-daniel-mueller 2020-07-23 predictor correlation plots, bin2d map plots
html 2e3691a jens-daniel-mueller 2020-07-23 Build site.
Rmd 26bdc0a jens-daniel-mueller 2020-07-23 new era label, predictor correlation check started
html 556e6cc jens-daniel-mueller 2020-07-23 Build site.
Rmd 1ce10e7 jens-daniel-mueller 2020-07-23 read full GLODAP Cant data set rather than joining again
Rmd 0cb3db2 jens-daniel-mueller 2020-07-23 started MLR fitting
Rmd cf8bc74 jens-daniel-mueller 2020-07-23 started MLR fitting
Rmd 0252675 jens-daniel-mueller 2020-07-23 modeling started
html fdfa7b9 jens-daniel-mueller 2020-07-22 Build site.
Rmd 6416150 jens-daniel-mueller 2020-07-22 cut gamma into slabs
html 0cecfbf jens-daniel-mueller 2020-07-22 Build site.
Rmd 48cf01f jens-daniel-mueller 2020-07-22 defined isoneutral slabs
Rmd 32ed280 jens-daniel-mueller 2020-07-22 sign in Cstar delta plot
html 44334f8 jens-daniel-mueller 2020-07-22 Build site.
Rmd c398496 jens-daniel-mueller 2020-07-22 plot update
html 0ff656b jens-daniel-mueller 2020-07-22 Build site.
Rmd 4b81f16 jens-daniel-mueller 2020-07-22 plot update
html 23038c8 jens-daniel-mueller 2020-07-22 Build site.
Rmd 09b3ca8 jens-daniel-mueller 2020-07-22 eding plain text, restructuring some code
html ac6308d jens-daniel-mueller 2020-07-22 Build site.
Rmd 77c9642 jens-daniel-mueller 2020-07-22 formatted plots
html 40b99cb jens-daniel-mueller 2020-07-22 Build site.
Rmd 8a49adf jens-daniel-mueller 2020-07-22 adjustment to reference year implemented
html bb9c002 jens-daniel-mueller 2020-07-21 Build site.
Rmd d2ed0f8 jens-daniel-mueller 2020-07-21 harmonied lat lon labeling
html e1488e6 jens-daniel-mueller 2020-07-19 Build site.
Rmd e688d6e jens-daniel-mueller 2020-07-19 formating
html f7ea007 jens-daniel-mueller 2020-07-19 Build site.
Rmd 0992256 jens-daniel-mueller 2020-07-19 plotted individual Cstar terms
html 22b588c jens-daniel-mueller 2020-07-18 Build site.
html fdfe5a0 jens-daniel-mueller 2020-07-17 Build site.
Rmd f7485c6 jens-daniel-mueller 2020-07-17 re run als emlr
html 56c3ed9 jens-daniel-mueller 2020-07-14 Build site.
html 74d4abd jens-daniel-mueller 2020-07-14 Build site.
html 1c511ce jens-daniel-mueller 2020-07-14 Build site.
Rmd e03016e jens-daniel-mueller 2020-07-14 split read in per data set
html 45ed0ea jens-daniel-mueller 2020-07-14 Build site.
Rmd dc1c56e jens-daniel-mueller 2020-07-14 tref calculated
html b1ece68 jens-daniel-mueller 2020-07-13 Build site.
Rmd 8eb1b22 jens-daniel-mueller 2020-07-13 cleaned data base file
Rmd 9e8f7f1 jens-daniel-mueller 2020-07-13 untracked changes
html 79312b2 jens-daniel-mueller 2020-07-13 Build site.
Rmd ffbc2a1 jens-daniel-mueller 2020-07-13 added Cstar calculation
html 090cfeb jens-daniel-mueller 2020-07-13 Build site.
Rmd e6a2ade jens-daniel-mueller 2020-07-13 added Cstar calculation

library(tidyverse)
library(lubridate)
library(patchwork)
library(broom)
library(GGally)

1 Required data

Required are:

  • clean version of GLODAPGLODAPv2.2020
  • C_ant from GLODAPv2_2016b_MappedClimatologies
  • annual mean atmospheric pCO2
GLODAP <- read_csv(here::here("data/GLODAPv2_2020/_summarized_data_files",
                              "GLODAPv2.2020_clean.csv"))

Cant_clim <- read_csv(here::here("data/GLODAPv2_2016b_MappedClimatologies/_summarized_files",
                                 "Cant.csv"))

co2_atm <- read_csv(here::here("data/pCO2_atmosphere/_summarized_data_files",
                               "co2_atm.csv"))

2 C*

2.1 Stoichiometric ratios

rCP <- 117
rNP <- 16

The stoichiometric nutrient ratios for the production and mineralization of organic matter were set to:

  • C/P: 117
  • N/P: 16

2.2 Calculation

GLODAP <- GLODAP %>% 
  mutate(rCP_phosphate = - rCP * phosphate,
         talk_05 = - 0.5 * talk,
         rNP_phosphate_05 = - 0.5 * rNP * phosphate,
         Cstar = tco2  + rCP_phosphate  + talk_05  + rNP_phosphate_05)

3 Reference year adjustment

The scaling factor for the reference year adjustment is an apriori estiamte of Cant at a given location and depth. Here, Cant from the GLODAP mapped Climatology was used.

Note that eq. 6 in Clement and Gruber (2018) misses pCO2 pre-industrial in the denominator. Here we use the equation published in Gruber et al. (2019).

3.1 Merge GLODAP data set with…

3.1.1 … Cant

Cant_clim <- Cant_clim %>% 
  drop_na()

# GLODAP_Cant_full <- full_join(GLODAP, Cant_clim)
# 
# GLODAP_Cant_full %>% write_csv(here::here("data/GLODAPv2_2020/_summarized_data_files",
#                                           "GLODAP_Cant_full.csv"))

GLODAP_Cant_full <- read_csv(here::here("data/GLODAPv2_2020/_summarized_data_files",
                                          "GLODAP_Cant_full.csv"))

The mapped Cant product was merged with GLODAP observation by:

  • using an identical 1x1° horizontal grid
  • linear interpolation of Cant from standard to sampling depth
GLODAP_Cant_observations_available <- GLODAP_Cant_full %>% 
  group_by(lat, lon) %>% 
  mutate(n_GLODAP = sum(!is.na(Cstar))) %>% 
  ungroup() %>% 
  filter(n_GLODAP > 0) %>% 
  select(-n_GLODAP)

rm(GLODAP_Cant_full)

GLODAP_Cant_observations_available <- GLODAP_Cant_observations_available %>% 
  group_by(lat, lon) %>% 
  arrange(depth) %>% 
  mutate(Cant_int = approxfun(depth, Cant, rule = 2)(depth)) %>% 
  ungroup()

ggplot() +
    geom_path(data = GLODAP_Cant_observations_available %>% 
              filter(lat == 48.5, lon == 165.5, !is.na(Cant)) %>% 
              arrange(depth),
            aes(Cant, depth, col="mapped")) +
  geom_point(data = GLODAP_Cant_observations_available %>% 
              filter(lat == 48.5, lon == 165.5, !is.na(Cant)) %>% 
              arrange(depth),
            aes(Cant, depth, col="mapped")) +
  geom_point(data = GLODAP_Cant_observations_available %>% 
              filter(lat == 48.5, lon == 165.5, date == ymd("2018-06-27")),
            aes(Cant_int, depth, col="interpolated")) +
  scale_y_reverse() +
  scale_color_brewer(palette = "Dark2", name="") +
  labs(title = "Cant interpolation to sampling depth - example profile")

GLODAP <- GLODAP_Cant_observations_available %>% 
  filter(!is.na(Cstar)) %>% 
  mutate(Cant = Cant_int) %>% 
  select(-Cant_int)

rm(GLODAP_Cant_observations_available, Cant_clim)

3.1.2 … Atmospheric pCO2

GLODAP <- left_join(GLODAP, co2_atm)

3.2 Calculate adjustment

GLODAP <- GLODAP %>% 
  group_by(era) %>% 
  mutate(tref = median(year)) %>% 
  ungroup()

tref <- GLODAP %>% 
  group_by(era) %>% 
  summarise(year = median(year)) %>% 
  ungroup()

co2_atm_tref <- right_join(co2_atm, tref) %>% 
  select(-year) %>% 
  rename(pCO2_tref = pCO2)

GLODAP <- full_join(GLODAP, co2_atm_tref)

rm(co2_atm, co2_atm_tref, tref)

GLODAP <- GLODAP %>% 
  mutate(Cstar_tref_delta = 
           ( (pCO2 - pCO2_tref) / (pCO2_tref - 280) ) * Cant,
         Cstar_tref = Cstar - Cstar_tref_delta)

3.3 Control plots

GLODAP %>% 
  ggplot(aes(Cstar_tref_delta)) +
  geom_histogram()

GLODAP %>% 
  sample_n(10000) %>% 
  ggplot(aes(year - tref, Cstar_tref_delta, col=Cant)) +
  geom_point() +
  scale_color_viridis_c() +
  labs(title = "random subsample 1e4")

4 Selected section plots

Selected sections are plotted to demonstrate the magnitude of various parameters and corrections relevant to C*.

cruises_meridional <- c("1041")

# cruises_meridional <- c("1041","1042", "260",
#                         "2011", "393", "1031", "394", "395",
#                         "1088", "983")

# cruises_zonal <- c()

GLODAP_cruise <- GLODAP %>% 
  filter(cruise %in% cruises_meridional)
bbox <- c(
  "xmin" = min(GLODAP_cruise$lat),
  "ymin" = min(GLODAP_cruise$depth),
  "xmax" = max(GLODAP_cruise$lat),
  "ymax" = max(GLODAP_cruise$depth)
)

grd_template <- expand.grid(
  lat = seq(from = bbox["xmin"], to = bbox["xmax"], by = 1),
  depth = seq(from = bbox["ymin"], to = bbox["ymax"], by = 50) # 20 m resolution
)

crs_raster_format <- " +proj=utm  +zone=33  +ellps=GRS80  +towgs84=0,0,0,0,0,0,0  +units=m  +no_defs"

grd_template_raster <- grd_template %>% 
  dplyr::mutate(Z = 0) %>% 
  raster::rasterFromXYZ( 
    crs = crs_raster_format)


# Generalized Additive Model
fit_GAM <- mgcv::gam( # using {mgcv}
  gamma ~ s(lat, depth),      # here come our X/Y/Z data - straightforward enough
  data = GLODAP_cruise      # specify in which object the data is stored
)

# Generalized Additive Model
interp_GAM <- grd_template %>% 
  mutate(Z = predict(fit_GAM, .)) %>% 
  raster::rasterFromXYZ(crs = crs_raster_format)

df <- raster::rasterToPoints(interp_GAM) %>% as_tibble()
colnames(df) <- c("X", "Y", "Z")
  
ggplot(df, aes(x = X, y = Y, fill = Z, z = Z))  +
  geom_raster()  +
  geom_contour(col="white")  +
  ggtitle(label = "interp GAM")  +
  scale_fill_viridis_c()  +
  scale_y_reverse() +
  coord_cartesian(expand = 0)
mapWorld <- borders("world", colour="gray60", fill="gray60")

GLODAP_cruise %>%
  arrange(date) %>% 
  ggplot(aes(lon, lat)) +
  mapWorld +
  geom_path() +
  geom_point(aes(col=date)) +
  coord_quickmap(expand = 0) +
  scale_color_viridis_c(trans = "date") +
  labs(title = paste("Cruise year:", mean(GLODAP_cruise$year))) +
  theme(legend.position = "bottom")

lat_section <- 
GLODAP_cruise %>%
  ggplot(aes(lat, depth)) +
  scale_y_reverse() +
  scale_color_viridis_c() +
  theme(legend.position = "bottom")

lat_section +
  geom_point(aes(col=tco2))

lat_section +
  geom_point(aes(col=talk))

lat_section +
  geom_point(aes(col=phosphate))

lat_section +
  geom_point(aes(col=rCP_phosphate))

lat_section +
  geom_point(aes(col=talk_05))

lat_section +
  geom_point(aes(col=rNP_phosphate_05))

lat_section +
  geom_point(aes(col=Cstar))

lat_section +
  geom_point(aes(col=Cant))

lat_section +
  geom_point(aes(col=-Cstar_tref_delta))

rm(mapWorld, lat_section, GLODAP_cruise)

5 MLR

5.1 Isoneutral slabs

slabs_Atl <- c(
-Inf,
26.00,
26.50,
26.75,
27.00,
27.25,
27.50,
27.75,
27.85,
27.95,
28.05,
28.10,
28.15,
28.20,
Inf)

slabs_Ind_Pac <- c(
-Inf,
26.00,
26.50,
26.75,
27.00,
27.25,
27.50,
27.75,
27.85,
27.95,
28.05,
28.10,
Inf)

The following boundaries for isoneutral slabs were defined:

  • Atlantic: -, 26, 26.5, 26.75, 27, 27.25, 27.5, 27.75, 27.85, 27.95, 28.05, 28.1, 28.15, 28.2,
  • Indo-Pacific: -, 26, 26.5, 26.75, 27, 27.25, 27.5, 27.75, 27.85, 27.95, 28.05, 28.1,
GLODAP_Atl <- GLODAP %>% 
  filter(basin == "Atlantic") %>% 
  mutate(gamma_slab = cut(gamma, slabs_Atl))

GLODAP_Ind_Pac <- GLODAP %>% 
  filter(basin == "Indo-Pacific") %>% 
  mutate(gamma_slab = cut(gamma, slabs_Ind_Pac))

GLODAP <- bind_rows(GLODAP_Atl, GLODAP_Ind_Pac)
rm(GLODAP_Atl, GLODAP_Ind_Pac)
GLODAP_cruise <- GLODAP %>% 
  filter(cruise %in% cruises_meridional)

lat_section <- 
GLODAP_cruise %>%
  ggplot(aes(lat, depth)) +
  scale_y_reverse() +
  theme(legend.position = "bottom")

lat_section +
  geom_point(aes(col=gamma)) +
  scale_color_viridis_c()

lat_section +
  geom_point(aes(col=gamma_slab)) +
  scale_color_viridis_d()

5.2 PO4* calculation

GLODAP <- GLODAP %>% 
  mutate(phosphate_star = phosphate - 16*nitrate  + 29)

5.3 Predictor correlation

GLODAP %>% 
  sample_frac(0.1) %>% 
  ggpairs(columns = c("Cstar",
                      "salinity",
                      "temperature",
                      "aou",
                      "oxygen",
                      "silicate",
                      "phosphate",
                      "phosphate_star"),
          ggplot2::aes(col = gamma_slab, fill = gamma_slab, alpha = 0.01)) +
      scale_fill_viridis_d() +
      scale_color_viridis_d() +
      labs(title = paste("Basin: all | era: all | subsample size: 10 %"))

Individual correlation plots for each basin and era are available upon request.

for (i_basin in unique(GLODAP$basin)) {
  for (i_era in unique(GLODAP$era)) {

# i_basin <- unique(GLODAP$basin)[1]
# i_era   <- unique(GLODAP$era)[1]
print(i_basin)
print(i_era)

p <- GLODAP %>% 
  filter(basin == i_basin, era == i_era) %>% 
  sample_frac(0.1) %>% 
  ggpairs(columns = c("salinity","temperature", "aou", "oxygen", "silicate", "phosphate", "phosphate_star"),
          ggplot2::aes(col = gamma_slab, fill = gamma_slab, alpha = 0.01)) +
      scale_fill_viridis_d() +
      scale_color_viridis_d() +
      labs(title = paste("Basin:", i_basin, "| era:", i_era, "| subsample size: 10%")) +
      theme(text = element_text(size=20))
  
png(here::here("output/figure/eMLR/predictor_correlation",
               paste("predictor_correlation", i_basin, i_era, ".png", sep = "_")),
    width = 20, height = 20, units = "in", res = 300)

print(p)

dev.off()

  }
}

5.4 Model fitting

GLODAP %>% write_csv(here::here("data/GLODAPv2_2020/_summarized_data_files",
                                "GLODAP_MLR_fitting_ready.csv"))
MLRs <- GLODAP %>%
  nest(data = -c(basin, era, gamma_slab)) %>% 
  mutate(
    fit = map(data, ~ lm(Cstar ~ salinity  + temperature  + aou  + oxygen  + silicate  + phosphate  + phosphate_star,
                         data = .x)),
    tidied = map(fit, tidy),
    glanced = map(fit, glance),
    augmented = map(fit, augment)
  )

MLRs_tidied <- MLRs %>% 
  unnest(tidied)

MLRs_tidied
# A tibble: 624 x 12
   era   basin gamma_slab data  fit   term  estimate std.error statistic
   <chr> <chr> <fct>      <lis> <lis> <chr>    <dbl>     <dbl>     <dbl>
 1 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  (Int~  1.05e+3  269.         3.91 
 2 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  sali~  1.17e+1    2.87       4.08 
 3 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  temp~ -1.52e+1    3.66      -4.16 
 4 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  aou   -6.83e-1    0.729     -0.938
 5 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  oxyg~ -1.40e+0    0.718     -1.96 
 6 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  sili~ -2.27e+0    0.285     -7.95 
 7 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  phos~ -1.05e+2    5.49     -19.2  
 8 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  phos~  3.07e-3    0.0245     0.125
 9 JGOF~ Atla~ (27.25,27~ <tib~ <lm>  (Int~  1.66e+3  103.        16.1  
10 JGOF~ Atla~ (27.25,27~ <tib~ <lm>  sali~  9.62e+0    1.74       5.52 
# ... with 614 more rows, and 3 more variables: p.value <dbl>, glanced <list>,
#   augmented <list>
MLRs_tidied <- MLRs_tidied %>% 
  select(era, basin, gamma_slab, term, estimate, p.value)

MLRs_tidied_wide <- MLRs_tidied %>% 
  select(-p.value) %>% 
  pivot_wider(names_from = era, values_from = estimate, names_prefix = "coeff_")

MLRs_tidied_wide <- MLRs_tidied_wide %>% 
  mutate(delta_coeff_J_G = coeff_GO_SHIP - coeff_JGOFS_WOCE,
         delta_coeff_G_n = coeff_new_era - coeff_GO_SHIP,
         delta_coeff_n_G = coeff_new_era - coeff_JGOFS_WOCE)

MLRs_tidied %>% 
  ggplot(aes(p.value, term, col=gamma_slab)) +
  geom_point() +
  facet_grid(basin~era)

MLRs_tidied %>% 
  filter(p.value < 0.05) %>% 
  ggplot(aes(p.value, term, col=gamma_slab)) +
  geom_point() +
  facet_grid(basin~era)

MLRs_tidied %>% 
  ggplot(aes(p.value, term)) +
  geom_boxplot() +
  facet_grid(basin~era)

MLRs %>% 
  unnest(glanced)
# A tibble: 78 x 19
   era   basin gamma_slab data  fit   tidied r.squared adj.r.squared sigma
   <chr> <chr> <fct>      <lis> <lis> <list>     <dbl>         <dbl> <dbl>
 1 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~     0.924         0.924  5.17
 2 JGOF~ Atla~ (27.25,27~ <tib~ <lm>  <tibb~     0.986         0.986  4.67
 3 JGOF~ Atla~ (27.5,27.~ <tib~ <lm>  <tibb~     0.988         0.988  4.17
 4 JGOF~ Atla~ (26.75,27] <tib~ <lm>  <tibb~     0.950         0.950  4.69
 5 JGOF~ Atla~ (26,26.5]  <tib~ <lm>  <tibb~     0.896         0.894  5.38
 6 JGOF~ Atla~ (-Inf,26]  <tib~ <lm>  <tibb~     0.768         0.743  7.46
 7 JGOF~ Atla~ (28.1,28.~ <tib~ <lm>  <tibb~     0.963         0.963  3.34
 8 JGOF~ Atla~ (27,27.25] <tib~ <lm>  <tibb~     0.975         0.975  4.91
 9 GO_S~ Atla~ (27.75,27~ <tib~ <lm>  <tibb~     0.984         0.983  4.34
10 GO_S~ Atla~ (27,27.25] <tib~ <lm>  <tibb~     0.977         0.977  4.91
# ... with 68 more rows, and 10 more variables: statistic <dbl>, p.value <dbl>,
#   df <dbl>, logLik <dbl>, AIC <dbl>, BIC <dbl>, deviance <dbl>,
#   df.residual <int>, nobs <int>, augmented <list>
MLRs %>% 
  unnest(augmented)
# A tibble: 177,773 x 21
   era   basin gamma_slab data  fit   tidied glanced Cstar salinity temperature
   <chr> <chr> <fct>      <lis> <lis> <list> <list>  <dbl>    <dbl>       <dbl>
 1 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  859.     36.6        18.1
 2 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  844.     35.5        14.6
 3 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  834.     35.4        13.9
 4 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  843.     35.3        13.0
 5 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  838.     35.3        13.1
 6 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  877.     36.1        16.5
 7 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  868.     36.1        16.4
 8 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  868.     36.1        15.7
 9 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  864.     36.0        15.5
10 JGOF~ Atla~ (26.5,26.~ <tib~ <lm>  <tibb~ <tibbl~  872.     36.1        16.2
# ... with 177,763 more rows, and 11 more variables: aou <dbl>, oxygen <dbl>,
#   silicate <dbl>, phosphate <dbl>, phosphate_star <dbl>, .fitted <dbl>,
#   .resid <dbl>, .std.resid <dbl>, .hat <dbl>, .sigma <dbl>, .cooksd <dbl>
mtcars <- mtcars %>% 
  select(mpg, disp, hp) %>% 
  as_tibble()

model <- "disp  + hp"

lm(data = mtcars, mpg ~ model)
temperature
salinity
phosphate
silicate
phosphate_star = phosphate  + (oxygen / 170) - 1.95
oxygen
aou
basins <- c("Atlantic", "Indo_Pacific")
slabs <- c("")

for (i_basin in basins) {
  for (i_slab in slabs) {
    
    
  }
  
}

sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_Germany.1252  LC_CTYPE=English_Germany.1252   
[3] LC_MONETARY=English_Germany.1252 LC_NUMERIC=C                    
[5] LC_TIME=English_Germany.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] GGally_2.0.0    broom_0.7.0     patchwork_1.0.1 lubridate_1.7.9
 [5] forcats_0.5.0   stringr_1.4.0   dplyr_1.0.0     purrr_0.3.4    
 [9] readr_1.3.1     tidyr_1.1.0     tibble_3.0.3    ggplot2_3.3.2  
[13] tidyverse_1.3.0 workflowr_1.6.2

loaded via a namespace (and not attached):
 [1] RColorBrewer_1.1-2 jsonlite_1.7.0     rstudioapi_0.11    generics_0.0.2    
 [5] magrittr_1.5       farver_2.0.3       gtable_0.3.0       rmarkdown_2.3     
 [9] vctrs_0.3.1        fs_1.4.2           hms_0.5.3          utf8_1.1.4        
[13] xml2_1.3.2         pillar_1.4.6       htmltools_0.5.0    haven_2.3.1       
[17] later_1.1.0.1      cellranger_1.1.0   tidyselect_1.1.0   plyr_1.8.6        
[21] knitr_1.29         git2r_0.27.1       whisker_0.4        lifecycle_0.2.0   
[25] pkgconfig_2.0.3    R6_2.4.1           digest_0.6.25      reshape_0.8.8     
[29] xfun_0.15          colorspace_1.4-1   rprojroot_1.3-2    stringi_1.4.6     
[33] yaml_2.2.1         evaluate_0.14      labeling_0.3       fansi_0.4.1       
[37] httr_1.4.1         compiler_3.6.3     here_0.1           cli_2.0.2         
[41] withr_2.2.0        backports_1.1.5    munsell_0.5.0      DBI_1.1.0         
[45] modelr_0.1.8       Rcpp_1.0.5         readxl_1.3.1       maps_3.3.0        
[49] dbplyr_1.4.4       ellipsis_0.3.1     assertthat_0.2.1   blob_1.2.1        
[53] tools_3.6.3        reprex_0.3.0       viridisLite_0.3.0  httpuv_1.5.4      
[57] scales_1.1.1       crayon_1.3.4       glue_1.4.1         rlang_0.4.7       
[61] rvest_0.3.5        promises_1.1.1     grid_3.6.3