动物园中不同的日期格式

发布于 2024-11-05 06:20:54 字数 1775 浏览 0 评论 0原文

我发现运行 R 2.12.1 的两个环境之间的行为存在差异。在第一个动物园中,动物园的行为符合预期。

> library(zoo)
> x.date <- as.Date(paste(2003, 2, c(1, 3, 7, 9, 14), sep = "-"))
    > x <- zoo(rnorm(5), x.date)
    > index(x)
    [1] "2003-02-01" "2003-02-03" "2003-02-07" "2003-02-09" "2003-02-14"
    > as.Date(index(x))
    [1] "2003-02-01" "2003-02-03" "2003-02-07" "2003-02-09" "2003-02-14"
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] ggplot2_0.8.9 proto_0.3-9.1 reshape_0.8.4 MASS_7.3-9    plyr_1.4      RODBC_1.3-2   zoo_1.6-4

loaded via a namespace (and not attached):
[1] lattice_0.19-13 tools_2.12.1

在另一个中,我得到以下输出:

> library(zoo)
> x.date <- as.Date(paste(2003, 2, c(1, 3, 7, 9, 14), sep = "-"))
> x <- zoo(rnorm(5), x.date)
> index(x)
[1] "02/01/2003 00:00:00.000 UTC" "02/03/2003 00:00:00.000 UTC" "02/07/2003 00:00:00.000 UTC" "02/09/2003 00:00:00.000 UTC" "02/14/2003 00:00:00.000 UTC"
> as.Date(index(x))
[1] "02/01/2003 00:00:00.000 UTC" "02/03/2003 00:00:00.000 UTC" "02/07/2003 00:00:00.000 UTC" "02/09/2003 00:00:00.000 UTC" "02/14/2003 00:00:00.000 UTC"
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] grid      grDevices graphics  stats     datasets  utils     methods   base

other attached packages:
[1] zoo_1.6-4     ggplot2_0.8.9 proto_0.3-8   reshape_0.8.4 plyr_1.4

loaded via a namespace (and not attached):
[1] digest_0.4.2    lattice_0.19-13

不仅奇怪,而且后一种行为会导致来自 ggplot2 的错误消息。有什么见解吗?提前致谢。

I am finding differences in behavior between two environments running R 2.12.1. In the first one zoo behaves as expected.

> library(zoo)
> x.date <- as.Date(paste(2003, 2, c(1, 3, 7, 9, 14), sep = "-"))
    > x <- zoo(rnorm(5), x.date)
    > index(x)
    [1] "2003-02-01" "2003-02-03" "2003-02-07" "2003-02-09" "2003-02-14"
    > as.Date(index(x))
    [1] "2003-02-01" "2003-02-03" "2003-02-07" "2003-02-09" "2003-02-14"
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] ggplot2_0.8.9 proto_0.3-9.1 reshape_0.8.4 MASS_7.3-9    plyr_1.4      RODBC_1.3-2   zoo_1.6-4

loaded via a namespace (and not attached):
[1] lattice_0.19-13 tools_2.12.1

In the other I get the following output:

> library(zoo)
> x.date <- as.Date(paste(2003, 2, c(1, 3, 7, 9, 14), sep = "-"))
> x <- zoo(rnorm(5), x.date)
> index(x)
[1] "02/01/2003 00:00:00.000 UTC" "02/03/2003 00:00:00.000 UTC" "02/07/2003 00:00:00.000 UTC" "02/09/2003 00:00:00.000 UTC" "02/14/2003 00:00:00.000 UTC"
> as.Date(index(x))
[1] "02/01/2003 00:00:00.000 UTC" "02/03/2003 00:00:00.000 UTC" "02/07/2003 00:00:00.000 UTC" "02/09/2003 00:00:00.000 UTC" "02/14/2003 00:00:00.000 UTC"
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: x86_64-unknown-linux-gnu (64-bit)

locale:
[1] C

attached base packages:
[1] grid      grDevices graphics  stats     datasets  utils     methods   base

other attached packages:
[1] zoo_1.6-4     ggplot2_0.8.9 proto_0.3-8   reshape_0.8.4 plyr_1.4

loaded via a namespace (and not attached):
[1] digest_0.4.2    lattice_0.19-13

Not only is it odd, but the latter behavior results in an error message from ggplot2. Any insights? Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文