summarise_for_trends: Summarise data by year and month

View source: R/test-trends.R

summarise_for_trendsR Documentation

Summarise data by year and month

Description

Compute annual summaries of water quality observations.

Usage

summarise_for_trends(
  data,
  breaks = NULL,
  FUN = "median",
  messages = getOption("wqbc.messages", default = TRUE)
)

Arguments

data

The data.frame to analyse.

breaks

A numeric vector used to create groups of consecutive months, if NULL the full year is used.

FUN

The function to use for yearly summaries, e.g. median, mean, or max.

messages

A flag indicating whether to print messages.

Details

The data must contain the columns Station, Date, Variable, Value, and Units.

Value

A tibble data.frame with rows for each Station, Variable, Year and month grouping.

Examples

# select one station
data(yuepilon)
data <- yuepilon[yuepilon$Station == "02EA005", ]
# estimate trend (using simple sen slope)
trend <- test_trends(data, messages = TRUE)
# get the data used in the test
datasum <- summarise_for_trends(data)
plot(datasum$Year, datasum$Value,
  main = paste("p-value =", round(trend$significance, 3)),
  ylab = "Value", xlab = "Year", las = 1
)

bcgov/wqbc documentation built on Feb. 11, 2023, 11:15 p.m.