library(zoo)
library(lubridate)
yearmon <- as.yearmon(c("01-10", "02-15", "03-30"), "%m-%y")
for (i in yearmon) {
if (year(yearmon[i]) > 2020) {
year(yearmon[i]) <- year(yearmon[i]) - 100
}}
Error in if (year(yearmona[i]) > 2020) { :
missing value where TRUE/FALSE needed
The idea is to take data with incorrect years > 2020, and put them back to 19XX form.