NO bug in Re: [R] strptime() bug? And additional problem in package "tseries"
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Aug 17 13:04:36 CEST 2004
There is no bug in R here. There was a change to DST in Spain at 2am on
2000-03-26, and they are *printed* as times in your locale, as documented.
Please read the posting guide and FAQ about what is a bug.
Also, please try not to confuse an object and its printed representation.
On Tue, 17 Aug 2004, javier garcia - CEBAS wrote:
> 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:
NO! That is an extract of *printing* lluvia.strptime, which will give you
the times in your current time zone, as documented.
> [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
I think you want to use as.POSIXct(lluvia.strptime, tz="GMT") to get
what you may have intended.
....
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list