I have a dataframe column containing character dates ( it is a SAS dataset that I'm reading in R) with formats such as "27JUN2022" "28JUN2022" "29JUN2022" "30JUN2022" "01JUL2022" "02JUL2022" "03JUL2022" etc.(equivalent to date9. format of SAS). when I convert it into numeric dates by mutate(as.Date( dataframe$variable, "%Y-%m-%d"), it gives NA as result. I have checked there is no NA in the column.
Is there any possible solution exists? the desired output is to simply convert the column in to numeric date.
thanks, but may I know what's the right format here, I did try with %d%m%y, but no help. can you suggest the right format to be used something similar to DDMMMYYYY?
Thanks @technocrat, is there any function to get the numeric dates in to the exact same format the way it is in character.
I did try mdy() , but I got NA.
technocrat said you use dmy. not mdy. dmy works. lubridate usually very slow in my limited experience
And if you follow the help to strptime (as suggested) you will see the different formats. You wanted:
Keep in mind that an object of class Date has both an internal aspect and a display aspect. @mikecrobp provides the level of control that you are looking for here.