I have a column of dates written as monthyear in the format: 11960 - this would be Jan 1960 121960 - this would be Dec 1960
I would like to convert this column into a day-month-year format assuming the first of the month as each date.
I have tried (using one number as an example as opposed to dt$dob)
x <- sprintf("%08d%", 11960) and then x <- as.date(x, format = "%d%m%Y)
but this gives me NAs as I assume it doesn't like the 00 at the start
So I tried pasting 01 to each value but this pastes it to the end (R noob here). I was thinking maybe posting 01 to the start and then using the sprintf function may work still:
- paste 01 to start of 11960 = 011960
- sprintf("%08d%", 011960) to maybe give 0101960?
- Then use as.Date to convert?
Many thanks for your help