BoulderCodeHub / RWDataPlyr

R package to read and manipulate data from RiverWareTM
3 stars 5 forks source link

get water year from year-month functions #46

Closed rabutler closed 7 years ago

rabutler commented 7 years ago

New function:

getWYFromYearMon <- function(xx)
{
  mm <- as.numeric(format(xx, '%m'))
  yy <- as.numeric(format(xx, '%Y'))
  # if OND then increase year by one for water year, else leave it the same
  yy[mm > 9] <- yy[mm > 9] + 1

  yy
}
rabutler commented 7 years ago

if xx is supposed to be yearmon, then check to make sure it is a yearmon first