Skip to content

Commit

Permalink
update docs somewhat
Browse files Browse the repository at this point in the history
add references to (d18Osw)|(temp)_calc and inherit them in the parent function
  • Loading branch information
japhir committed Oct 9, 2023
1 parent 85142b6 commit ddc3d31
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 57 deletions.
2 changes: 1 addition & 1 deletion R/bootstrap_means.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#' @param D47 The column name in `data` with the clumped isotope values.
#' @param Nsim The number of bootstraps you want to run. Defaults to the
#' number of rows in `calib`.
#' @return A tibble with bootstrapped slope-intercept pair.
#' @returns A tibble with bootstrapped slope-intercept pair.
#' @export
bootstrap_means <- function(data,
group,
Expand Down
9 changes: 4 additions & 5 deletions R/d18Osw_calc.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@
#'
#' @param temperature The formation temperature (in °C).
#' @inheritParams temp_calc
#' @return The oxygen isotope composition of the sea water in VSMOW.
#' @returns The oxygen isotope composition of the sea water in VSMOW.
#' @author Ilja J. Kocken
#' @references
#' Kim, S.-T., & O’Neil, J. R. (1997). Equilibrium and nonequilibrium oxygen isotope effects in synthetic carbonates. Geochimica et Cosmochimica Acta, 61(16), 3461–3475. https://doi.org/10.1016/S0016-7037(97)00169-5
#'
#' Bemis, B. E., Spero, H. J., Bijma, J., & Lea, D. W. (1998). Reevaluation of the oxygen isotopic composition of planktonic foraminifera: Experimental results and revised paleotemperature equations. Paleoceanography, 13(2), 150–160. https://doi.org/10.1029/98PA00070
#' @inherit supported_equations references
#' @examples
#' d18Osw_calc(3, 2, "KimONeil1997")
#' @export
d18Osw_calc <- function(d18Occ, temperature, equation = NULL) {
equation <- equation_supported(equation)
Expand Down
67 changes: 42 additions & 25 deletions R/equation_supported.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,9 @@
#' Also parses equation name into our internal simplified code.
#' See details for which equations are currently supported.
#'
#' - TODO: add all supported equations and references somewhere.
#'
#' - Kim & O'Neil 1997 as recalculated by Bemis et al., 1998:
#'
#' \eqn{T = a + b(\delta_{c} - \delta_{w}) + c(\delta_{c} - \delta_{w})^2}{T = a + b(delta_c - delta_w) + c(delta_c - delta_w)^2},
#'
#' where T is in °C, \eqn{\delta_{c}}{delta_c} is in VPDB and \eqn{\delta_{w}}{delta_w} is in VMOW.
#'
#' - Marchitto et al., 2014:
#'
#' \eqn{(\delta_{cp} - \delta_{ws} + 0.27) = -0.245\pm0.005t + 0.0011\pm0.0002t^{2} + 3.58±0.02}{(delta_cp - delta_ws + 0.27) = -0.245+-0.005t + 0.0011+-0.0002t^2 + 3.58+-0.02}.
#'
#' @param equation Character vector with equation reference.
#' @param equation Character vector with equation reference. Must be one of [supported_equations()].
#' @returns Character vector of cleaned up equation reference. Gives an error if it's currently not supported.
equation_supported <- function(equation) {
supported_equations <- c(
"Shackleton1974",
"ErezLuz1983",
"KimONeil1997", # NOTE: as recalculated in Bemis 1998!
## "Bemis1998",
"Marchitto2014"
)

# default
if (is.null(equation)) {
equation <- "KimONeil1997"
Expand Down Expand Up @@ -65,10 +45,47 @@ equation_supported <- function(equation) {
}
}

if (!equation %in% supported_equations) {
cli::cli_abort(c("Equation {.var {equation}} is not implemented",
"i" = "Supported equation{?s}: {.and {supported_equations}}",
"i" = "Feel free to submit a pull request!"))
if (!equation %in% supported_equations()) {
cli::cli_abort(c("Equation {.var {equation}} is not implemented/reckognized.",
"i" = "Supported equation{?s}: {.and {supported_equations()}}.",
"x" = "Maybe you have misspelled it?",
"i" = "Feel free to submit a pull request to add the equation!"))
}
return(equation)
}

#' Supported d18Osw, d18Occ, temperature relationship equations.
#'
#' Defaults to Kim & O'neil 1997 as modified by Bemis et al., 1998.
# #'
# #' - Kim & O'Neil 1997 as recalculated by Bemis et al., 1998:
# #'
# #' \eqn{T = a + b(\delta_{c} - \delta_{w}) + c(\delta_{c} - \delta_{w})^2}{T = a + b(delta_c - delta_w) + c(delta_c - delta_w)^2},
# #'
# #' where T is in °C, \eqn{\delta_{c}}{delta_c} is in VPDB and \eqn{\delta_{w}}{delta_w} is in VMOW.
# #'
# #' - Marchitto et al., 2014:
# #'
# #' \eqn{(\delta_{cp} - \delta_{ws} + 0.27) = -0.245\pm0.005t + 0.0011\pm0.0002t^{2} + 3.58±0.02}{(delta_cp - delta_ws + 0.27) = -0.245+-0.005t + 0.0011+-0.0002t^2 + 3.58+-0.02}.
# #'
#' @examples
#' supported_equations()
#' @references
#' Shackleton, N. J. (1974). Attainment of isotopic equilibrium between ocean water and the benthic foraminifera genus _Uvigerina_: Isotopic changes in the ocean during the last glacial. _Colloques Internationaux Du CNRS_, _219_, 203–209.
#'
#' Erez, J., & Luz, B. (1983). Experimental paleotemperature equation for planktonic foraminifera. _Geochimica et Cosmochimica Acta_, _47(6)_, 1025–1031. https://doi.org/10.1016/0016-7037(83)90232-6
#'
#' Kim, S.-T., & O’Neil, J. R. (1997). Equilibrium and nonequilibrium oxygen isotope effects in synthetic carbonates. _Geochimica et Cosmochimica Acta_, _61(16)_, 3461–3475. https://doi.org/10.1016/S0016-7037(97)00169-5
#'
#' Bemis, B. E., Spero, H. J., Bijma, J., & Lea, D. W. (1998). Reevaluation of the oxygen isotopic composition of planktonic foraminifera: Experimental results and revised paleotemperature equations. _Paleoceanography_, _13(2)_, 150–160. https://doi.org/10.1029/98PA00070
#'
#' Marchitto, T. M., Curry, W. B., Lynch-Stieglitz, J., Bryan, S. P., Cobb, K. M., & Lund, D. C. (2014). Improved oxygen isotope temperature calibrations for cosmopolitan benthic foraminifera. _Geochimica et Cosmochimica Acta_, _130_, 1–11. https://doi.org/10.1016/j.gca.2013.12.034
supported_equations <- function() {
c(
"Shackleton1974",
"ErezLuz1983",
"KimONeil1997", # NOTE: as recalculated in Bemis 1998!
## "Bemis1998",
"Marchitto2014"
)
}
2 changes: 1 addition & 1 deletion R/filter_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' @param data A dataframe with columns `outlier`, `broadid`
#' @param group Column name of the groups.
#' @return A dataframe with outliers, standards, and NAs filtered out.
#' @returns A dataframe with outliers, standards, and NAs filtered out.
#' @export
filter_outliers <- function(data, group) {
data |>
Expand Down
1 change: 0 additions & 1 deletion R/supported_equations.R

This file was deleted.

9 changes: 4 additions & 5 deletions R/temp_calc.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
#' @param d18Occ The oxygen isotope composition of the carbonate in VPDB.
#' @param d18Osw The oxygen isotope composition of the sea water in VSMOW
#' @param equation Character vector with the equation to use. Defaults to Kim & O'Neil, 1997.
#' @return The temperature in degrees Celsius.
#' @returns The temperature in degrees Celsius.
#' @author Ilja J. Kocken
#' @inherit supported_equations references
#' @examples
#' temp_calc(3, 0, "KimONeil1997")
#' @export
#' @references
#' Kim, S.-T., & O’Neil, J. R. (1997). Equilibrium and nonequilibrium oxygen isotope effects in synthetic carbonates. Geochimica et Cosmochimica Acta, 61(16), 3461–3475. https://doi.org/10.1016/S0016-7037(97)00169-5
#'
#' Bemis, B. E., Spero, H. J., Bijma, J., & Lea, D. W. (1998). Reevaluation of the oxygen isotopic composition of planktonic foraminifera: Experimental results and revised paleotemperature equations. Paleoceanography, 13(2), 150–160. https://doi.org/10.1029/98PA00070
temp_calc <- function(d18Occ, d18Osw, equation = NULL) {
equation <- equation_supported(equation)
if (equation == "Shackleton1974") {
Expand Down
2 changes: 1 addition & 1 deletion R/temp_d18Osw_calc.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#' @param calib A dataframe with draws from the bootstrapped (or Bayesian)
#' temperature regression. Should have columns `slope` and `intercept`.
#' @inheritParams d18Osw_calc
#' @return Same as boot but with additional columns `temp` and `d18Osw`.
#' @returns Same as boot but with additional columns `temp` and `d18Osw`.
#' @export
temp_d18Osw_calc <- function(boot, calib, equation = NULL, Nsim = NULL) {
if (is.null(Nsim)) {
Expand Down
13 changes: 11 additions & 2 deletions man/d18Osw_calc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 1 addition & 14 deletions man/equation_supported.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions man/temp_calc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ddc3d31

Please sign in to comment.