#' Returns the next publication date of the monthly outputs.
#'
#' Used in construction of file paths to get to raw data and also for printing in text of monthly factsheet.
#' @param x A date, usually generated by lubridate::today()
#' @return A data frame giving publication date, date for relevant data and month as a number for data
#' @examples
#' \dontrun{
#' next_pub <- mo_next_pub_date(lubridate::today())
#' }
#' @export
mo_next_pub_date <- function(x){
# want two outputs:
# the full date of next publication date
# the month and year of most recent set of data
# Most recent data is two month lag on next pub date
first_wed_this <- first_wednesday(lubridate::floor_date(lubridate::today(), "month"))
first_wed_next <- first_wednesday(lubridate::floor_date(lubridate::today(), "month") %m+%
lubridate:::months(1))
if(first_wed_this <= lubridate::today()){
pub_date <- format(first_wed_next, "%d %B %Y")
data_date <- format(first_wed_next %m-% lubridate:::months(2), "%B %Y")
data_date_2 <- format(first_wed_next %m-% lubridate:::months(2), "%b %Y")
data_date_number <- paste0(format(first_wed_next %m-% lubridate:::months(2), "%m"),
". ")
}else{
pub_date <- format(first_wed_this, "%d %B %Y")
data_date <- format(first_wed_this %m-% lubridate:::months(2), "%B %Y")
data_date_2 <- format(first_wed_this %m-% lubridate:::months(2), "%b %Y")
data_date_number <- paste0(format(first_wed_this %m-% lubridate:::months(2), "%m"),
". ")
}
z <- data.frame(pub_date, data_date, data_date_2,
data_date_number, stringsAsFactors = FALSE)
return(z)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.