R/filter_recent_times.r

Defines functions filter_recent_times

#' @title Filter Recent Times
#' @description Trim data to most recent x timepoints and fill in rows for missing times
#' @param df the data frame that has a date column
#' @param x number of most recent months
#' @return dataframe of filtered data
#' @importFrom lubridate %m-% 
filter_recent_times <- function(df, x){
  threshold <- max(df$report_month) %m-% months(x-1)
  df[df$report_month >= threshold,]
}
Display-Lab/goals-of-care documentation built on Nov. 21, 2020, 2:44 a.m.