When it converts the time to Date it does it relative to the
GMT time zone, not your time zone.  When its July 1st
in your time zone it can be June 30th in the GMT time zone.

See the article in R News 4/1 Help Desk, and the table at the
end of the article in particular, on ways to handle this.

On 9/23/05, Vittorio <[EMAIL PROTECTED]> wrote:
> Dear All,
> I'm happily extracting data of temperature from an oracle db
> under R via RODBC. After manipulating the extracted data I put them
> into a data.frame 'dati' which is as follows:
>
> > dati
>         DATA tm.
> UDINE/RIVOLTO tm.TORINO/CASELLE
> 1  2005-07-01
> 22.35             23.80
> 2  2005-07-02            22.70
> 22.85
> 3  2005-07-03            23.80             24.30
> 4  2005-07-
> 04            23.80             25.40
> ..........
>
> and
>
> > str(dati)
> `data.frame':   11 obs. of  3 variables:
>  $ DATA             :'POSIXct',
> format: chr  "2005-07-01" "2005-07-02" "2005-07-03" "2005-07-04" ...
>  $
> tm.UDINE/RIVOLTO : num  22.4 22.7 23.8 23.8 21.8 ...
>  $ tm.
> TORINO/CASELLE: num  23.8 22.9 24.3 25.4 21.8 ...
>  - attr(*,
> "reshapeWide")=List of 5
>  ..$ v.names: NULL
>  ..$ timevar: chr "NOME"
>  ..$ idvar  : chr "DATA"
>  ..$ times  : Factor w/ 2 levels
> "TORINO/CASELLE",..: 2 1
>  ..$ varying: chr [1, 1:2] "tm.UDINE/RIVOLTO"
> "tm.TORINO/CASELLE"
> >
>
> You see that the first field DATA is POSIXct
>
> Now
> > dati[1,1]
> [1] "2005-07-01 ora solare Europa occidentale"
>
> BUT
>
> >
> as.Date(dati[1,1],"%d%m%Y")
> [1] "2005-06-30"
>
> How come?
> What is wrong
> with it (or better with me)?
>
> Ciao
> Vittorio

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to