Matches each rule's Pattern (a regular expression, case ignored)
against the transaction Description. The first matching rule wins;
unmatched rows get "Other". From the Tracking spending chapter.
See also
Other tracking spending:
subscription_opportunity_cost()
Examples
transactions <- data.frame(
Description = c("SAFEWAY #123", "NETFLIX.COM", "SHELL OIL", "ATM FEE")
)
rules <- data.frame(
Pattern = c("safeway|trader joe", "netflix|spotify", "shell|chevron"),
Category = c("Groceries", "Subscriptions", "Gas")
)
apply_rules(transactions, rules)
#> Description Category
#> 1 SAFEWAY #123 Groceries
#> 2 NETFLIX.COM Subscriptions
#> 3 SHELL OIL Gas
#> 4 ATM FEE Other