Reputation: 73
I have dataset with column Date such
1-Apr-08
18-Sep-09
And I want to transform them to
01/04/08
18/09/09
I try
format(as.Date(d, "%d-%b-%y"), "%d/%m/%y")
but it doesn't work
UPD I found that my code doesn't work because system language of my PC is russian. When I try to transform 1-Апр-08, it works (Апрель = April).
Upvotes: 0
Views: 125
Reputation: 73
My code was correct. It didn't work because system language of my PC was russian. For example, When I tried to transform 1-Апр-08, it worked routinely (Апрель is April in russian)
Upvotes: 1
Reputation: 10352
When your d
is a character, you can use:
format(as.Date(d, "%d-%b-%y"), "%d/%m/%y")
If not, then use
format(as.Date(as.character(d), "%d-%b-%y"), "%d/%m/%y")
Upvotes: 2