How to convert a string factor into Date?

前端 未结 5 1018
情话喂你
情话喂你 2021-01-24 17:52

I\'m working with the London crime dataset which contains dates in an integer format. I melted them and now they have become factors.

For example, \"

5条回答
  •  广开言路
    2021-01-24 17:59

    One possibility is to use lubridate

    ss <- factor("X200801")
    
    library(lubridate)
    ymd(paste(sub("X", "", ss), "01", sep = ""))
    #[1] "2008-01-01"
    

提交回复
热议问题