tidal_codes: Creates tidal codes

View source: R/tidal_codes.R

tidal_codesR Documentation

Creates tidal codes

Description

Creates a numerical code for the tide state in relation to the closest low tide peak.

Usage

tidal_codes(observations, tide_table, round_digits = 1)

Arguments

observations

data to which tide code will be appended; must have a column named "date" with datetime info in POSIXct format.

tide_table

a tide table upon tide codes will be calculated; must have a column named "date" with datetime info in POSIXct format and another column named "type" with values 'High' or 'Low'.

round_digits

defines the accuracy of tide codes. If round_digits = 1 (default), observations are coded per hour. If round_digits = 0.5, creates half-hour tide codes.

Details

For each observation, the time difference to the nearest low tide is calculated (in hours) and coded into a numerical category where 0 represents low tide and 6 high tide. If tide is ebbing, values are negative. If tide is rising values are positive.

Note: To ensure tide code is calculated accurately for the observations given, you must ensure that observation dates contain a time zone attribute. You can define this with the field tz in as.POSIXct. For help with accepted time zone codes, see OlsonNames.

Value

The observations data frame entered with a new column named 'tide_code'.

Examples

tidalCodes(observations, tides_january)

CamiloCarneiro/eneRgetics documentation built on April 23, 2023, 4:20 p.m.