我如何找到“原产地”? R中的日期 [英] How do I find "origin" of a Date in R

查看:63
本文介绍了我如何找到“原产地”? R中的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个使用as.Date函数转换的日期,例如 2015-01-01 如何找到其用作参考的日期?是的,我尝试了?Date ,并尝试使用默认原点,但是在1945年有了几天。我想知道一般如何做,所以我没有

If I have a date that i've converted using the as.Date function, e.g. "2015-01-01" how can I find out what date it is using as reference for its origin? And yes, I tried ?Date, and tried using the default origin, but got days in 1945. I would like to know how to do this generally so I don't have to manually check every time I do operations on dates.

推荐答案

如文档中所述,起源参数不会在 Date 对象中创建相应的属性;

As described in the documentation, the origin argument does not create a corresponding attribute in the Date object; it's just to make input easier from integers (e.g., from Excel, SAS, etc. that use different origins).

A dput

A dput 确认 Date s是普通旧数字:

A dput confirms that Dates are plain old numbers:

d <- as.Date("2000-01-01")
dput(d)
# structure(10957, class = "Date")

(我改用 str(d),但这有时似乎隐藏了信息。 )

(I'd use str(d) instead, but that sometimes seems to hide information.)

这篇关于我如何找到“原产地”? R中的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆