#' @import lubridate
#' @export
last_month <- function(now = Sys.Date()) {
month(now) <- month(now) - 1
day(now) <- 1
return(now)
}
#' @export
last_week <- function(now = Sys.Date()) {
return(now - dweeks())
}
#' @export
elapsed_months <- function(from, to = Sys.Date(), absolute = TRUE) {
if (is.character(from))
from <- as.Date(from)
if (is.character(to))
to <- as.Date(to)
nmonths <- 12 * (year(to) - year(from)) + (month(to) - month(from))
return(ifelse(absolute, abs(nmonths), nmonths))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.