R/get-year-LAST-censo.R

Defines functions get_year_LAST_censo

Documented in get_year_LAST_censo

#' @title Get the LAST year of the Census time series
#'
#' @description Identifica e extrai o último ano da série histórica do censo
#'
#' @param tb_censo_full \code{tibble} contendo a base completa do censo
#'     após tratamento e limpeza por meio da função \code{\link{extract_and_clean_censo_full}}.
#'
#' @return \code{vector} do tipo \code{numeric} contendo o ano final da série.
#'
#' @family get_ano
#'
#' @examples
#' \dontrun{
#'
#' ano_LAST_censo <- get_year_LAST_censo(tb_censo_full)
#'
#' }
#' @export
#'
get_year_LAST_censo <- function(tb_censo_full) {

  # obtem ano do ultimo censo
  ano_LAST_censo <- tb_censo_full %>% # import magrittr pro namespace
    dplyr::summarise(max(lubridate::year(NU_ANO_CENSO))) %>%
    dplyr::collect() %>%
    unlist()

  return(unname(ano_LAST_censo))

}
allanvc/projPNLD documentation built on Oct. 4, 2020, 7:43 a.m.