简体   繁体   English

as.character的奇怪行为

[英]Strange behavior with as.character

I have a vector or POSIXct and when I do as.character() on it, it returns numbers instead of the characters. 我有一个向量或POSIXct,当我as.character()执行as.character()时,它返回数字而不是字符。 I unfortunately cannot reproduce this with toy data but this is what is happening: 不幸的是,我无法用玩具数据重现此信息,但这是正在发生的事情:

d = as.POSIXct(c( "2015-09-08 17:42:07.456 GMT","2015-09-08 17:42:19.778 GMT"))
class(d) ##this returns POSIXct

but as.character(d) returns 但是as.character(d)返回

"1441740168.0001", "1441740168.0001"

Why am I getting "1441740168.0001", "1441740168.0001" instead of dates in character format? 为什么我得到"1441740168.0001", "1441740168.0001"而不是字符格式的日期?

Internally it represents dates as seconds passed since origin moment in time. 在内部,它表示自原始时刻开始经过的秒数。 Consult this for details. 咨询了解详情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM