本文介绍了将日期转换为R中的可读格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将数据集中的日期格式转换为R可读的格式.我的想法是使用strftime函数:
I am trying to convert a date format in my dataset to something readable by R. My idea was to use the strftime function:
time = strftime("Tue Jan 01 19:28:39 EST 2013", format="%a %b %d %H:%M:%S")
但是它导致了以下错误:
But it resulted in the following error:
Error in as.POSIXlt.character(x, tz = tz) :
character string is not in a standard unambiguous format
我该如何解决?
推荐答案
使用 as.POSIXct
代替:
time = as.POSIXct("Tue Jan 01 19:28:39 EST 2013", format="%a %b %d %H:%M:%S EST %Y")
从技术上讲,相同的 format
掩码也应与 strftime
一起使用,但不适用于我的系统.YMMV.
The same format
mask should technically work with strftime
as well, but did not work on my system. YMMV.
这篇关于将日期转换为R中的可读格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!