inputSource: Input Sediment Sources

View source: R/inputSource.R

inputSourceR Documentation

Input Sediment Sources

Description

Selects and extracts the source samples from the dataset, computing mean, standard deviation, and sample size (n) when the input is in raw format. When pre-aggregated data is provided, column names are normalized to Mean_/SD_ so that all downstream functions work correctly.

Usage

inputSource(data, na.omit = TRUE)

Arguments

data

Data frame containing source and mixture data.

na.omit

Logical. If TRUE (default), NA values are omitted when computing mean and SD.

Value

A data.frame where each row represents a sediment source containing:

id

Factor or character vector identifying the source group.

Mean_...

Mean tracer values for each tracer.

SD_...

Standard deviations of tracer values for each tracer.

n

Sample size for each source group.

Examples

# Example 1: Processing raw sample data
raw_df <- data.frame(
  ID = paste0("S", 1:9),
  Group = rep(c("SourceA", "SourceB", "Mixture"), each = 3),
  Tracer1 = c(10, 12, 11, 20, 22, 21, 15, 16, 17),
  Tracer2 = c(5, 6, 5, 15, 14, 16, 10, 11, 12)
)
inputSource(raw_df)

# Example 2: Normalizing pre-averaged data with legacy column names
summary_df <- data.frame(
  ID = c("Src1", "Src2", "Mix"),
  Group = c("SourceA", "SourceB", "Mixture"),
  mean_Tracer1 = c(11.0, 21.0, 16.0),
  mean_Tracer2 = c(5.33, 15.0, 11.0),
  sd_Tracer1 = c(1.0, 1.0, 1.0),
  sd_Tracer2 = c(0.58, 1.0, 1.0),
  n = c(3, 3, 3)
)
inputSource(summary_df)


OceanTracer documentation built on Oct. 15, 2026, 5:09 p.m.