R/extract_year.R

Defines functions .extract_year

Documented in .extract_year

#' Helper function that extracts year from a dataframe and raises error
#' if more than one.
#'
#' @param df dataframe to extract year from
#'
#' @return year as integer
.extract_year <- function(df) {
    year <- unique(df$year)

    if (length(year) > 1) {
        stop("Too many years.")
    }

    return(year)
}
mkiang/narcan documentation built on Sept. 26, 2024, 7:18 a.m.