Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

calcWaterYear

Extract WY from a date


Description

Determine the correct water year based on a calendar date.

Usage

calcWaterYear(dateVec)

Arguments

dateVec

vector of dates as character ("YYYY-DD-MM"), Date, or POSIXct. Numeric does not work.

Details

This function calculates a water year based on the USGS definition that a water year starts on October 1 of the year before, and ends on September 30. For example, water year 2015 started on 2014-10-01 and ended on 2015-09-30. See the USGS definition at https://water.usgs.gov/nwc/explain_data.html.

Value

numeric vector indicating the water year

Examples

x <- seq(as.Date("2010-01-01"), as.Date("2010-12-31"), by="month")
calcWaterYear(x)

y <- c("2010-01-01", "1994-02", "1980", "2009-11-01", NA)
calcWaterYear(y)

dataRetrieval

Retrieval Functions for USGS and EPA Hydrologic and Water Quality Data

v2.7.10
CC0
Authors
Laura DeCicco [aut, cre] (<https://orcid.org/0000-0002-3915-9487>), Robert Hirsch [aut] (<https://orcid.org/0000-0002-4534-075X>), David Lorenz [aut], Jordan Read [ctb], Jordan Walker [ctb], Lindsay Carr [ctb], David Watkins [aut] (<https://orcid.org/0000-0002-7544-0700>), David Blodgett [ctb], Mike Johnson [aut] (<https://orcid.org/0000-0002-5288-8350>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.