convert string to date

I need help converting a variable of string to date. I have tried converting the column with (as.Date) but since the format of data is unconventional all I get is NA as value.

glimpse (data1$proxy)
Factor w/ 97 levels "01dec2011","01jun2010",..: 82 65 69 71 90 86 72 56 39 26 ...

Anyone eager to help? :slight_smile:


You need to select a format that recognize abbreviated month names, in the correct locale. See ?strptime
Packages like lubridate or anytime may help

#> [1] "2011-12-01"
#> [1] "2011-12-01"

Created on 2019-12-09 by the reprex package (v0.3.0)

Also, for date, try to import them as character directly and not factor when you are creating or reading. (see stringsAsFactors in data.frame for example)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.