I am trying to find the repeated purchases over years.
I have been looking at the lubridate() package but all of the examples deal with the time format with date, month, year (or even more with time) but my data only have month and year.
My goal is to parse the time format into 12 months per each year, so I can find the repeated purchases.
Beyond the built-in shorthand functions (e.g., ymd()), lubridate can parse all sorts of date formats using parse_date_time(). See the link for all the details, but for instance you can do this:
A month-year date is going to be represented internally as the first day of the month, but in general this doesn't matter — any time you need to output the date for display, you can format it as just month-year using format() or lubridate::stamp().
Yup! The symbols are also listed on the parse_date_time() documentation page I linked above. That's worth a read because while parse_date_time() uses the strptime() symbols, it's more lenient in its interpretations (on purpose, since its goal is to be a more friendly and flexible parser than the base functions) — the differences are spelled out in the documentation.
The parse_date_time() page is long, but if you're someone who finds themselves reading in date and time data, I think it's well worth studying carefully. It's a fantastically useful tool that can do a lot more than maybe meets the eye.