在R中转换时间格式
Converting time format in R
我对时间数据的观察之一是"Wed Oct 31 13:42:46 2007"。
我想将格式转换为“2007-10-31 13:42:46”(删除 Wed)。
我如何转换它?
正如@thelatemail所说
x <- "Wed Oct 31 13:42:46 2007"
x <- as.POSIXct(x, format = "%a %b %d %T %Y", tz = "GMT")
# %a day of week, %b month of year, %d day of month as decimal, %T H:M:S, %Y year with century
x
[1] "2007-10-31 13:42:46 GMT"
我对时间数据的观察之一是"Wed Oct 31 13:42:46 2007"。 我想将格式转换为“2007-10-31 13:42:46”(删除 Wed)。 我如何转换它?
正如@thelatemail所说
x <- "Wed Oct 31 13:42:46 2007"
x <- as.POSIXct(x, format = "%a %b %d %T %Y", tz = "GMT")
# %a day of week, %b month of year, %d day of month as decimal, %T H:M:S, %Y year with century
x
[1] "2007-10-31 13:42:46 GMT"