This would be the basic logic handling for those date strings by length. You'll need to add logic for the "context", given that we have no idea how these are structured. I'm putting them in a vector for example:
dates <- c(112001, 1112001)
lapply(dates, function(x) {
x <- as.character(x)
if (nchar(x) == 6) {
as.Date(sprintf("0%s0%s%s", substr(x,1,1), substr(x,2,2), substr(x,3,6)), format="%m%d%Y")
} else if (nchar(x) == 7) {
as.Date(sprintf("0%s%s%s", substr(x,1,1), substr(x,2,3), substr(x,4,7)), format="%m%d%Y")
} else {
as.Date(x, format="%m%d%Y")
}
})
## [[1]]
## [1] "2001-01-01"
##
## [[2]]
## [1] "2001-01-11"