View source: R/safe_year_min.R
safe_year_min | R Documentation |
Safely goes back N years for monthly data. This is an improved version of using filter(date >= last(date) library(tidyverse);library(lubridate) df <- data.frame(date = rmsfuns::dateconverter(StartDate = lubridate::ymd(20180831), EndDate = lubridate::ymd(20210228), Transform = 'calendarEOM')) df Note that this gives 25 months, not 24. Instead, use: df
safe_year_min(datesel, N = 2)
Ra |
N months back |
N months back
library(tidyverse);library(lubridate)
df <- data.frame(date = rmsfuns::dateconverter(StartDate = lubridate::ymd(20180831), EndDate = lubridate::ymd(20210531), Transform = 'calendarEOM'))
df %>% filter(date >= safe_year_min(last(date), N = 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.