nf_to_annual: Sum monthly natural flow data to annual data

View source: R/nf_to_annual.R

nf_to_annualR Documentation

Sum monthly natural flow data to annual data

Description

nf_to_annual() sums nfd, and xts data from monthly data to annual data.

Usage

nf_to_annual(x, ...)

## S3 method for class 'xts'
nf_to_annual(x, ..., year = "cy", full_year = TRUE)

## S3 method for class 'nfd'
nf_to_annual(x, ..., full_year = TRUE, recompute = FALSE, keep_monthly = TRUE)

## S3 method for class 'crss_nf'
nf_to_annual(x, ..., full_year = TRUE, recompute = FALSE, keep_monthly = TRUE)

## S3 method for class 'crssi'
nf_to_annual(x, ..., recompute = FALSE)

Arguments

x

An object inheriting from xts.

...

Other parameters passed to methods.

year

"cy" or "wy" to sum over the calendar or water year, respectively. For nfd like objects, this must either match the year attribute of x or keep_monthly must be FALSE.

full_year

Only return sums for full years when TRUE. Otherwise, will sum all months in a year, even if that's a partial year.

recompute

If nfd object already has annual data, should the annual data be recomputed. An error will post if it has annual data and recompute is FALSE.

keep_monthly

If TRUE the monthly data are kept in the returned object, otherwise they are dropped.

See Also

nf_to_intervening(), nf_to_total()

Examples

# can sum monthly data to annual and get the existing stored annual data
library(CoRiverNF)
ann <- nf_to_annual(monthlyTot)
all.equal(ann, cyAnnTot, check.attributes = FALSE)

# for nfd objects, annual data will be added to object and the monthly 
# data are kept by default
nf <- nfd(
  monthlyTot["2000/2002"], 
  flow_space = "total", 
  time_step = "monthly"
)

nf2 <- nf_to_annual(nf)

# nf2 now has annual data, and monthly data

nf2 <- nf_to_annual(nf, keep_monthly = FALSE)
# nf2 no longer has monthly data


BoulderCodeHub/CRSSIO documentation built on July 2, 2023, 5:15 p.m.