agedepth: Create Age Depth Function

Description Usage Arguments Value Examples

Description

Creates a function that transforms depths into ages based on a set of known depths and known ages. Interpolation is linear, and extrpolation is based on average sedimentation rates. Error is not interpolated but is included in the final output if information for that depth is requested (useful for putting error bars on age-depth model plots). If depths are provided, this funcion returns a data.frame of the interpolated/extrapolated values.

Usage

1
2
agedepth(knowndepths, knownages, age_err = NA, extrapolate = "average",
  depths = NULL, ...)

Arguments

knowndepths

A vector of depths with known ages

knownages

A vector of ages of the depths specified

age_err

A vector of error values for the ages specified

extrapolate

An extrapolation method for depths beyond the maximum specified depth: one of 'average' or 'last'.

depths

If specified, will return a data.frame of the depth, age, error, and type of each depth specified.

...

If depths is specified, arguments to pass to the age depth function (currently cols=c("depth", "age", "err", "type")) is supported.

Value

A function with the signature function(depth, cols=c("depth", "age", "err", "type")) that transforms a depth into a data.frame with the given cols.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# make an age depth function and use it
ad_func <- agedepth(c(17, 10, 6, 0), c(1880, 1940, 1970, 2015.9))
ad_func(4)
ad_func(6)
ad_func(c(0, 1, 2, 3, 4, 5, 6))

# specify depths to return a data.frame instead of a function
agedepth(c(17, 10, 6, 0), c(1880, 1940, 1970, 2015.9), depths=c(0, 1, 2, 3, 4, 5, 6))

# make an age-depth plot using ggplot
library(ggplot2)
ages <- agedepth(c(17, 10, 6, 0), c(1880, 1940, 1970, 2015.9),
                 depths=c(0, 6, 10, 17:22))
ggplot(ages, aes(x=age, y=depth, lty=type)) + geom_line() + scale_y_reverse()

paleolimbot/ofcores documentation built on May 24, 2019, 6:13 p.m.