ym_get_wateryear: Get the water year from a year-month (yearmon) value

View source: R/yearmon_helpers.R

ym_get_wateryearR Documentation

Get the water year from a year-month (yearmon) value

Description

ym_get_wateryear() returns the water year (assumed to be October - September) from a zoo::yearmon object.

Usage

ym_get_wateryear(ym)

getWYFromYearmon(ym)

Arguments

ym

An object of class zoo::yearmon, or something that can be successfully converted to zoo::yearmon.

Details

If the argument is not already a yearmon object, it will attempt to convert it to a zoo::yearmon. This may result in unexpected results. For example, the string "12-1-1906" can be converted to a zoo::yearmon, however, it will not convert to "Dec 1906" as you might desire. It will convert to "Jan 0012" since it is not a format expected by zoo::as.yearmon(). Therefore, a warning is posted when the function attempts to convert to zoo::yearmon, and it is safer to ensure ym is already a zoo::yearmon.

Value

The water year as a numeric.

Examples

ym_get_wateryear(zoo::as.yearmon(c("Dec 1906", "Oct 1945", "Jul 1955")))
ym_get_wateryear("2000-11")


BoulderCodeHub/RWDataPlyr documentation built on May 8, 2023, 3:55 a.m.