[R] another date conversion
Erin Hodgess
hodgess at gator.uhd.edu
Mon Mar 22 20:40:36 CET 2004
Dear R People
Here is an interesting problem:
> library(pastecs)
> a <- 1:100
> b <- daystoyears(a,datemin="1/1/2003",dateformat="m/d/Y")
> b
[1] 2002.999 2003.002 2003.005 2003.008 2003.010 2003.013 2003.016 2003.018 2003.021 2003.024 2003.027 2003.029 2003.032
[14] 2003.035 2003.038 2003.040 2003.043 2003.046 2003.049 2003.051 2003.054 2003.057 2003.060 2003.062 2003.065 2003.068
[27] 2003.070 2003.073 2003.076 2003.079 2003.081 2003.084 2003.087 2003.090 2003.092 2003.095 2003.098 2003.101 2003.103
[40] 2003.106 2003.109 2003.112 2003.114 2003.117 2003.120 2003.123 2003.125 2003.128 2003.131 2003.133 2003.136 2003.139
[53] 2003.142 2003.144 2003.147 2003.150 2003.153 2003.155 2003.158 2003.161 2003.164 2003.166 2003.169 2003.172 2003.175
[66] 2003.177 2003.180 2003.183 2003.185 2003.188 2003.191 2003.194 2003.196 2003.199 2003.202 2003.205 2003.207 2003.210
[79] 2003.213 2003.216 2003.218 2003.221 2003.224 2003.227 2003.229 2003.232 2003.235 2003.238 2003.240 2003.243 2003.246
[92] 2003.248 2003.251 2003.254 2003.257 2003.259 2003.262 2003.265 2003.268 2003.270
> require(chron)
Loading required package: chron
Attaching package 'chron':
The following object(s) are masked _by_ .GlobalEnv :
dates times
[1] TRUE
> seq.dates(B,by="days",length=length(b))
[1] (06/26/75 23:59:01) (06/27/75 23:59:01) (06/28/75 23:59:01) (06/29/75 23:59:01) (06/30/75 23:59:01) (07/01/75 23:59:01)
[7] (07/02/75 23:59:01) (07/03/75 23:59:01) (07/04/75 23:59:01) (07/05/75 23:59:01) (07/06/75 23:59:01) (07/07/75 23:59:01)
[13] (07/08/75 23:59:01) (07/09/75 23:59:01) (07/10/75 23:59:01) (07/11/75 23:59:01) (07/12/75 23:59:01) (07/13/75 23:59:01)
[19] (07/14/75 23:59:01) (07/15/75 23:59:01) (07/16/75 23:59:01) (07/17/75 23:59:01) (07/18/75 23:59:01) (07/19/75 23:59:01)
[25] (07/20/75 23:59:01) (07/21/75 23:59:01) (07/22/75 23:59:01) (07/23/75 23:59:01) (07/24/75 23:59:01) (07/25/75 23:59:01)
[31] (07/26/75 23:59:01) (07/27/75 23:59:01) (07/28/75 23:59:01) (07/29/75 23:59:01) (07/30/75 23:59:01) (07/31/75 23:59:01)
[37] (08/01/75 23:59:01) (08/02/75 23:59:01) (08/03/75 23:59:01) (08/04/75 23:59:01) (08/05/75 23:59:01) (08/06/75 23:59:01)
[43] (08/07/75 23:59:01) (08/08/75 23:59:01) (08/09/75 23:59:01) (08/10/75 23:59:01) (08/11/75 23:59:01) (08/12/75 23:59:01)
[49] (08/13/75 23:59:01) (08/14/75 23:59:01) (08/15/75 23:59:01) (08/16/75 23:59:01) (08/17/75 23:59:01) (08/18/75 23:59:01)
[55] (08/19/75 23:59:01) (08/20/75 23:59:01) (08/21/75 23:59:01) (08/22/75 23:59:01) (08/23/75 23:59:01) (08/24/75 23:59:01)
[61] (08/25/75 23:59:01) (08/26/75 23:59:01) (08/27/75 23:59:01) (08/28/75 23:59:01) (08/29/75 23:59:01) (08/30/75 23:59:01)
[67] (08/31/75 23:59:01) (09/01/75 23:59:01) (09/02/75 23:59:01) (09/03/75 23:59:01) (09/04/75 23:59:01) (09/05/75 23:59:01)
[73] (09/06/75 23:59:01) (09/07/75 23:59:01) (09/08/75 23:59:01) (09/09/75 23:59:01) (09/10/75 23:59:01) (09/11/75 23:59:01)
[79] (09/12/75 23:59:01) (09/13/75 23:59:01) (09/14/75 23:59:01) (09/15/75 23:59:01) (09/16/75 23:59:01) (09/17/75 23:59:01)
[85] (09/18/75 23:59:01) (09/19/75 23:59:01) (09/20/75 23:59:01) (09/21/75 23:59:01) (09/22/75 23:59:01) (09/23/75 23:59:01)
[91] (09/24/75 23:59:01) (09/25/75 23:59:01) (09/26/75 23:59:01) (09/27/75 23:59:01) (09/28/75 23:59:01) (09/29/75 23:59:01)
[97] (09/30/75 23:59:01) (10/01/75 23:59:01) (10/02/75 23:59:01) (10/03/75 23:59:01)
>
Why is it that the seq.dates values come back as 1975, please?
What am I doing wrong, please? (I'm sure it's something incredibly simple)
Thanks in advance!
R for Windows 1.8.1
Sincerely,
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: hodgess at gator.uhd.edu
More information about the R-help
mailing list