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

前端 未结 4 1136
南旧
南旧 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:50

    If you don't want to deal with Levels, try this:

    First convert your data into character:

    data<- as.character(mydata[1,1])

    Then give the date format you need, for example:

    date<- format(as.POSIXct(data, tz="EST"),"%Y-%m-%d %H")

提交回复
热议问题