Example

Suppose you want to review transactions from the past 7 days.

Without lubridateExtras, this might look like this:

transactions %>%
  filter(date >= today() - days(7))

Even in this straightforward example it can be difficult to remember: does the >= operator evaluate before or after the - operator? We can add parantheses to make the expression more explicit but that also adds more syntax.

lubridateExtra aims to remove this sort of ambiguity and make the intent clearer through convenience functions. With lubridateExtras, we could rewrite this as follows:

transactions %>%
  filter(date >= days_ago(7))

This accomplishes the exact same thing.