check_pretreat: Check the input data

View source: R/check_pretreatment.R

check_pretreatR Documentation

Check the input data

Description

This functions does some check-up on the data frame used for the tapas::pretreatment_data() function, which requires that the depth and age scales are continuous. In other words, for every i-th row, it requires that

  • CmBot[i] > CmTop[i]

  • AgeBot[i] > AgeTop[i]

  • there shouldn't be duplicate values in the CmTop, CmBot, AgeTop, and AgeBot columns.

Usage

check_pretreat(series)

Arguments

series

The input data frame. A matrix with the following columns: CmTop, CmBot, AgeTop, AgeBot, Volume, and one or more columns with the data which should be resampled (variables).

Details

If any of the following is true:

  • any CmBot[i] < CmTop[i]

  • AgeBot[i] < AgeTop[i]

  • there are duplicate values in one of the columns CmTop, CmBot

...the function returns a fatal error and stops.

The function also fixes a few things:

Add missing samples: If any CmBot[i] < CmTop[i+1], then the function adds a new row [j = i+1] to fill in the missing CmTop and CmBot values. Thus, the added samples will have CmTop[j] == CmBot[i] and CmBot[j] == CmTop[i+1]. The new age scale values will be: AgeTop[j] == AgeBot[i] and AgeBot[j] == AgeTop[i+1].

Check for overlapping sample depths: If any CmBot[i] > CmTop[i+1], the function flags a warning due to the presence of overlapping sample depths. To get a data.frame of the overlapping sample depths, use the tapas::get_overlaps() function.

Check presence of slumps: If after these checks any AgeTop[i] == AgeBot[i], then the function removes the flagged rows, and creates new corrected CmTop and CmBot scales that exclude slumps, such that CmBot[i] > CmTop[i] and CmBot[i] == CmTop[i+1].

Value

A data frame.

Author(s)

Walter Finsinger

See Also

get_overlap_depths

Examples

co <- tapas::co_char_data
co_check <- tapas::check_pretreat(co)


wfinsinger/tapas documentation built on Aug. 22, 2024, 4:28 a.m.