SRtrend5: Five-Year Linear Trend

View source: R/SRtrend5.R

SRtrend5R Documentation

Five-Year Linear Trend

Description

Calculate the five-year linear trend of a time series of data, by the specified grouping variables.

Usage

SRtrend5(df, x, group, time, lasttime = NULL)

Arguments

df

A data frame containing the data to be averaged.

x

A character scalar, naming the element of df with the numeric estimates to be averaged.

group

A character scalar, naming the element of df with the grouping variable.

time

A character scalar, naming the element of df with the numeric variable denoting time.

lasttime

A numeric scalar, the last value of time that should be used to calculate the trend. The default, NULL, results in lasttime being set to the maximum time in df.

Value

A data frame with one row per group and last time, giving the intercept (Y.5nt), slope (Y.5sl), and P value (Y.5pv) for the five-year linear trend.

Examples

rawdat <- data.frame(
  Year = 1990 + c(0:5, 8:9, 2:3, 5:8),
  Type = rep(1:2, c(8, 6)),
  Y = c(1:12, 9, 7)*10
)
SRtrend5(rawdat, "Y", "Type", "Year")
SRtrend5(rawdat, "Y", "Type", "Year", lasttime=1995)

JVAdams/GLFC documentation built on Jan. 5, 2023, 12:59 a.m.