Learn R Programming

avstrat (version 0.1.1)

add_depths: Add standardized depth information to stratigraphic layer data

Description

add_depths() takes a data frame of stratigraphic layer information and calculates standardized thickness and depth values. It ensures required columns are present, converts thickness and depth units to centimeters, derives a plotting thickness, and computes top, bottom, and middle depths for each layer within a stratigraphic section. The function is designed to handle input where layers are defined either by order and thickness or with absolute start and stop depth values.

Usage

add_depths(df)

Value

A tibble with the original data plus:

  • thickness_min_cm, thickness_max_cm: thickness values converted to cm.

  • depth_top_cm, depth_bottom_cm: depth values converted to cm.

  • thickness_plot: representative thickness used for plotting.

  • thickness_plot_warning: message if no thickness was available.

  • Depth_top, Depth_bottom, Depth_middle: calculated depths (cm). Rows without sufficient information are dropped.

Arguments

df

A data frame containing stratigraphic layer information. The following columns are required depending on the method:

Always required

  • stratsection_name: Unique identity of the section (repeated for each layer).

  • stratlayer_name: Unique identity of the layer.

  • stratmeasuremethod: One of "order and thickness" or "start and stop depth".

  • stratlayer_order_start_at_top: Logical, does ordering start at the top (TRUE) or bottom (FALSE)? For "start and stop depth", this defines if the reference "depth" is the top or bottom of the section.

If stratmeasuremethod == "order and thickness"

  • stratlayer_order: Integer order of layers within the section.

  • thickness_units: One of "meters", "centimeters", "millimeters".

  • At least one of thickness_typical, thickness_min, or thickness_max.

If stratmeasuremethod == "start and stop depth"

  • depth_units: One of "meters", "centimeters", "millimeters".

  • depth_top: Absolute depth of the top of the layer.

  • depth_bottom: Absolute depth of the bottom of the layer.

Other columns are carried through unchanged. Missing expected columns are added automatically and filled with NA.

Details

The function groups data by stratsection_name and orders layers according to stratlayer_order_start_at_top. Depths are computed cumulatively if only thickness is provided, or taken directly from absolute depth columns if available.

Examples

Run this code
# Example data is included with the package
data("example_data_strat", package = "avstrat")

# Order + thickness method (section "fake1")
df1 <- subset(example_data_strat, stratsection_name == "fake1")
add_depths(df1)

# Start/stop depth method (section "fake3")
df2 <- subset(example_data_strat, stratsection_name == "fake3")
add_depths(df2)

Run the code above in your browser using DataLab