Description Usage Arguments Details Value Examples
Given a date, compute the corresponding water year (hydrological year).
1 2 | water_year(x, origin = "din", as.POSIX = FALSE,
assign = c("majority", "start", "end"), ...)
|
x |
a vector, implicit coercion to class POSIXlt is performed. |
origin |
a vector of length one specifying the month in which the hydrological year starts. Four different ways of defining the beginning of a hydrological year are supported: a character string like "din" or "usgs" representing a definition of an institution (see Details), an integer number between 1 and 12, a character string of the month name (possibly abbreviated) or POSIX/Date object from which only the month is taken. |
as.POSIX |
logical, if TRUE return value is of class |
assign |
a character vector of length one, deciding how a hydrological year is labeled. Depending on the climate, the hydrological year can start earlier or later than the calendar year. Usually the hydrological year "equals" the calendar year for the longest period of months they have in common. Alternatively a water year can also be designated by the calendar year in which it starts or ends. |
... |
arguments, passed on to |
Currently, it is only supported to start a hydrological year on the 1st of a month.
There are shorthands for a few established definitions:
start | description | |
"din" | 1st of November | DIN 4049 (default), as used in Austria and Germany |
"usgs" | 1st of October | USGS, the United States Geological Survey |
"swiss" | 1st of October | as defined by the swiss "Bundesamt f. Energie" (BFE) |
"glacier" | 1st of September | Widely used in glaciology |
Its convenient to have the water year as a factor with levels even for year without observations. For example, otherwise years without observations don't appear after aggregation.
a factor representing the hydrological year.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # generating monthly sequence
x <- seq(from = as.Date("1992-01-01"),
by = "months", length.out = 12)
# specifying the beginning with a decimal number
water_year(x, origin = 10)
# using a month name
water_year(x, origin = "Jul") # can be abbreviated
water_year(x, origin = "july") # case insensitive
# using an POSIX or Date object
water_year(x, origin = as.Date("2012-08-22")) # only month is taken
water_year(x, origin = as.POSIXct("2012-08-22"))
# or by specifying an institution
water_year(x, origin = "usgs")
|
Loading required package: xts
Loading required package: zoo
Attaching package: 'zoo'
The following objects are masked from 'package:base':
as.Date, as.Date.numeric
Loading required package: lmom
Loading required package: lattice
[1] 1992 1992 1992 1992 1992 1992 1992 1992 1992 1993 1993 1993
Levels: 1992 1993
[1] 1992 1992 1992 1992 1992 1992 1993 1993 1993 1993 1993 1993
Levels: 1992 1993
[1] 1992 1992 1992 1992 1992 1992 1993 1993 1993 1993 1993 1993
Levels: 1992 1993
[1] 1992 1992 1992 1992 1992 1992 1992 1993 1993 1993 1993 1993
Levels: 1992 1993
[1] 1992 1992 1992 1992 1992 1992 1992 1993 1993 1993 1993 1993
Levels: 1992 1993
[1] 1992 1992 1992 1992 1992 1992 1992 1992 1992 1993 1993 1993
Levels: 1992 1993
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.