R/six_months_only.R

Defines functions six_months_only

Documented in six_months_only

#' six_months_only
#'
#' An easy function for getting only the most recent six months from a data frame
#' @param df A data frame
#' @export

six_months_only <- function(df) {

  m <- df %>%
    distinct(month) %>%
    arrange(desc(month)) %>%
    slice(1:6)

  m <- m[['month']]

  df <- df %>%
    filter(month %in% m)

  return(df)
}
neugelb/neugelbtools documentation built on July 7, 2020, 1:17 a.m.