CONVERTING INTO DATE and TIME PROBLEM

as.POSIXct( x$time, format ="%d/%m/%Y %H:%M")
I'm not getting the conversion by this.
but when I take individual value like:
as.POSIXct( "10/05/2008 10:20", format ="%d/%m/%Y %H:%M")
then by this I am getting it changed.

Can you please post the outputs of class(x$time) and head(x$time)?

1 Like

class- factor
head:
[1] 01/09/2016 00:00 01/09/2016 01:00 01/09/2016 02:00 01/09/2016 03:00
[5] 01/09/2016 04:00 01/09/2016 05:00
720 Levels: 01/09/2016 00:00 01/09/2016 01:00 ... 30/09/2016 23:00

Factors are internally represented as integers so maybe as.POSIXct() is having trouble converting them to dates. Can you try this instead?

as.POSIXct(as.character(levels(x$time)), format ="%d/%m/%Y %H:%M")
1 Like

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