[R] strptime() bug? And additional problem in package "tseries"

javier garcia - CEBAS rn001 at cebas.csic.es
Tue Aug 17 12:48:24 CEST 2004


Hi all, I've got some problems with irts objects, one of which could be a bug:

1) Read a table with several columns from Postgres and the first column is 
Timestamp with timezone (this is OK). An extract is:

raincida$ts:
 [2039] "25/03/2000 22:00:00 UTC" "25/03/2000 23:00:00 UTC"
 [2041] "26/03/2000 00:00:00 UTC" "26/03/2000 01:00:00 UTC"
 [2043] "26/03/2000 02:00:00 UTC" "26/03/2000 03:00:00 UTC"
 [2045] "26/03/2000 04:00:00 UTC" "26/03/2000 05:00:00 UTC"

2) Try to extract time from this column of the dataframe (bug?)

> lluvia.strptime <- strptime(raincida$ts, format="%d/%m/%Y %H:%M:%S")

# An extract is:

 [2038] "2000-03-25 21:00:00" "2000-03-25 22:00:00" "2000-03-25 23:00:00"
 [2041] "2000-03-26 00:00:00" "2000-03-26 01:00:00" "2000-03-26 03:00:00"
 [2044] "2000-03-26 03:00:00" "2000-03-26 04:00:00" "2000-03-26 05:00:00"

# note that element [2043] is wrong. This happens several times in 
# the dataset. This will produce an eventual error because of omitted
# and duplicated values 

3) The additional problem is related with function time() for irts objects.
I try to make an irts from several columns of the table read:

> rain.irts <- 
irts(as.POSIXct(lluvia.strptime,tz="GMT"),cbind(raincida[[8]],raincida[[9]],raincida[[10]],raincida[[11]],raincida[[12]],raincida[[13]],raincida[[14]])) 

# this step doesn't seem to have any further problem. An extract is:

2000-03-25 22:00:00 GMT 0.275 0 0.07875 0.2 0 0.025 23.65
2000-03-25 23:00:00 GMT 0.275 0 0.07875 0.2 0 0.025 23.65
2000-03-26 00:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322
2000-03-26 01:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322
2000-03-26 03:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322
2000-03-26 03:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322
2000-03-26 04:00:00 GMT 0 0 0.001667 0.008333 0 0 0.5322

# But I try to extract the time part:

>time(rain.irts, tz='GMT')

# An extract is:

 [2039] "2000-03-25 23:00:00 CET"  "2000-03-26 00:00:00 CET"
 [2041] "2000-03-26 01:00:00 CET"  "2000-03-26 03:00:00 CEST"
 [2043] "2000-03-26 05:00:00 CEST" "2000-03-26 05:00:00 CEST"

# There isn't a way for this time to be shown as 'GMT'? I guess sometimes it 
is shown as 'CET' and other times as 'CEST' depending of the lag between the 
locale and gmt (utc) times. But for me this is an additional problem as the 
output shows one or two hours more that UTC time.

Thanks all, and best regards,

Javier G.




More information about the R-help mailing list