R - Help in Converting factor to date (%m/%d/%Y %H:%M)

前端 未结 4 1135
南旧
南旧 2021-01-23 20:57

I am importing a data frame into R, but R is not recognizing the columns with the dates as being in dates format.

> mydata[1,1] [1] 1/1/2003 0:00 216332 Levels:

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-23 21:42

    When dealing with dates, I find lubridate can be very helpful:

    library(lubridate)
    mydata[, 1] <- mdy_hm(mydata[, 1])
    

提交回复
热议问题