I have a dataset with dates in the format like 20170911.
Normally with other datasets I work with as.Date from the lubridate package and it works out pretty well.
However, when I apply the as.Date function, it does not work out with this dataset.
I get a date for the year which is impossible e.g. 57195-09-11
I don't get it, there seems to be a problem with the structure, I guess?
Maybe it is because there are no separators included like . or - between the numbers?
Can anyone help me out?
As an example
Datum <- c(20170911, 20151107, 20101131)
as.Dateis base R, not from thelubridatepackage. You may be thinking oflubridate::as_date()- the lubridate solution would belubridate::as_date(as.character(Datum)). Also note your last date returnsNAsince November 31 is not a valid date.