[R] Problem with DateVisit-gives wrong year?
Jim Lemon
jim at bitwrit.com.au
Wed Apr 17 13:26:07 CEST 2013
On 04/17/2013 09:18 PM, Pancho Mulongeni wrote:
> Hi I have the following factor of dates that I want to converted to Date class so I can extract the month
>> test.date
> [1] 14/05/2012 14/05/2012 14/05/2012 14/05/2012 14/05/2012 14/05/2012
> [7] 14/05/2012 14/05/2012 14/05/2012 14/05/2012
> 201 Levels: 01/10/2012 01/11/2012 01/12/2012 02/07/2012 ... 28/09/2012
> I use code below
> ntest.date<-as.Date(test.date,'%d/%m/%y')
>
> but the output has the wrong year, and the reverse order
> ntest.date
> [1] "2020-05-14" "2020-05-14" "2020-05-14" "2020-05-14" "2020-05-14"
> [6] "2020-05-14" "2020-05-14" "2020-05-14" "2020-05-14" "2020-05-14"
>
> What am I doing wrong?
> I dare not say the word 'bug'
Hey Pancho,
It is not the bug, it is the case. Try:
ntest.date<-as.Date(test.date,"%d/%m/%Y")
Jim
More information about the R-help
mailing list