Skip to contents

Calculates annual statistics and fits a linear trend to detect long-term changes in the data.

Usage

calculate_annual_trends(data, variable = "wave_height", time_col = "time")

Arguments

data

Data frame with time and value columns

variable

Name of the variable (default: "wave_height")

time_col

Name of the time column (default: "time")

Value

List with:

  • annual_stats: annual mean, max, etc.

  • trend_model: linear model for trend

  • trend_per_decade: change per decade with significance

Examples

set.seed(1)
data <- data.frame(
  time = seq(as.POSIXct("2020-01-01"), by = "hour", length.out = 1000),
  wave_height = 2 + sin(seq(0, 20, length.out = 1000)) + rnorm(1000, 0, 0.3)
)
result <- calculate_annual_trends(data)
#>  Calculating annual trends...
#> ! Insufficient years for trend analysis
#>  Calculating annual trends...

#>  Calculating annual trends... [8ms]
#> 
result$trend_per_decade
#> [1] NA
result$p_value
#> [1] NA