[R] Strange behaviour of as.Date function
Vittorio
vdemart1 at tin.it
Fri Sep 23 15:06:29 CEST 2005
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
More information about the R-help
mailing list