R/eom.R

#' @title
#' End of Month
#'
#' @description
#' Return the last day of the month for each date in a vector of dates
#'
#' @details
#' Returns the last day of the month for each date in a vector of dates
#'
#' @param dates A vector of dates
#'
#' @export
#'
#' @examples
#' eom(as.Date("2016-2-14"))
#' eom(seq.Date(as.Date("2015-1-1"), as.Date("2015-12-31"), by="month"))

eom <- function(dates, p = as.POSIXlt(dates)){
  # Returns the last day of the month for each Date in dates

  p$mon <- p$mon + 1
  p$mday <- 0
  return(as.Date(p))
}
ben519/trinalysis documentation built on May 12, 2019, 10:56 a.m.