将因子转换为R中的DateTime
我有一个属于因子数据类型的柱面,但是时间戳以这种格式:
%y-%m-%dt%h:%m:%s
$ fg_stop_time : Factor w/ 8 levels "2022-05-16T20:38:19",..: 4 8
无法获得。
df$new_time <-strptime(x = as.character(df1$fg_stop_time), format = "%Y-%m-%d %H:%M:%S")
我似乎 之间。我该如何识别“ T”?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
lubridate
这怎么样?posixct [1:1],格式:“ 2022-05-16 20:38:19”
How about this with
lubridate
?POSIXct[1:1], format: "2022-05-16 20:38:19"
只需在
格式中添加
int
Strptime
或as.posixct
(最好使用> as.posixct
asStrptime
返回list
with Posixlt classJust add the
T
within theformat
instrptime
oras.POSIXct
(it may be better to useas.POSIXct
asstrptime
returns alist
with POSIXlt class