I have imported some data into R, which looks like the following:
dateTime temp
1 10/25/2005 12:00:00 15.50
2 10/25/2005 1:00:00 15.49
3 10/25/2005 2:00:00 15.52
4 10/25/2005 3:00:00 15.50
5 10/25/2005 4:00:00 15.50
6 10/25/2005 5:00:00 15.46
where the class of the dateTime column of the data.frame is factor and the second column is numeric.
I try to convert the dateTime into POSIXct format as follows:
dat[,1] <- as.POSIXct(dat[,1])
but receive the error
Error in as.POSIXlt.character(as.character(x), ...) :
character string is not in a standard unambiguous format
which I think is to do with the dateTime varying in the format that hour is presented e.g. 12, 1, 2 etc and not 12, 01, 02.
How can I change this to POSIXct?