我有下面的数据
library(lubridate)
Date <- c("18.11.2016 21:03:41", "19.11.2016", "20.11.2016","21.11.2016")
df = data.frame(Date)
df我要得到
df$Date
[1] "2016-11-18" "2016-11-19" "2016-11-20" "2016-11-21"&试着像现在这样转换它
df$Date = dmy(df$Date)我得到了
Warning message:
1 failed to parse. 怎么修呢?
发布于 2016-11-21 18:48:05
试试这个:
s <- c("2004-03-21 12:45:33.123456", # ISO
"2004/03/21 12:45:33.123456", # variant
"20040321", # just dates work fine as well
"Mar/21/2004", # US format, also support month abbreviation or full
"rapunzel") # will produce a NA
p <- toPOSIXct(s)
options("digits.secs"=6) # make sure we see microseconds in output
print(format(p, tz="UTC")多读一些关于它的这里。
https://stackoverflow.com/questions/40727249
复制相似问题