I have another problem. I have a date time column in a data frame, which when i upload it comes as factor and I want it to be POSIXct
str(ida$DATA_TRAMA)
Factor w/ 1122932 levels "1-1-2010 00:00:51",..: 629101 629120 629128 629132 629139 629149
And i want it to be POSIXct (%Y-%m-%d %H:%M:%S) format. I already tried all of these methods but none of them seem to work. Whichever i apply it gets NA values.
ida$DATA_TRAMA<- as.POSIXct(ida$DATA_TRAMA,format='%d/%m/%Y %H:%M:%S')
ida$DATA_TRAMA<- as.POSIXct(as.character(ida$DATA_TRAMA), format = "%d/%m/%Y %H:%M")
ida$DATA_TRAMA <-format(ida$DATA_TRAMA, "%Y-%m-%d")
ida$DATA_TRAMA <- as.POSIXct(ida$DATA_TRAMA, format = '%Y-%m-%d:%H:%M:%S')
ida$DATA_TRAMA <- as.POSIXlt(as.character(ida$DATA_TRAMA), format="%m/%d/%Y %H:%M:%S")
ida$DATA_TRAMA <- strptime(ida$DATA_TRAMA,"%Y-%m-%d %H:%M:%S")
Do you know how to do it?
Copyright Notice:Content Author:「Hanna」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/54310692/converting-factor-date-time-columns-into-posixct-in-r