#' Extract Water Year
#'
#' Extract year from Date object and convert to water year (Oct - Sep)
#' @param x Date object
#' @export
#' @return NULL
#' @examples
#' NULL
waterYear <- function(x){
if (class(x) != "Date") stop("Must supply a 'Date' object")
dt_year <- lubridate::year(x)
dt_mon <- lubridate::month(x)
dt_wy <- dt_year
dt_wy[dt_mon >= 10] <- dt_wy[dt_mon >= 10] + 1
return(dt_wy)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.