Hello everyone,

I'm having a big trouble with which seems to be a bug in as.POSIXct()
date-time conversion. I have massive GPS datasets in which each location
has it's own date and time attribute. As I convert them to POSIXct format,
1300 cases (of about half a million locations) simply return NA values.

I picked up a small sample of failed cases and normal cases to demonstrate
the problem (see below). Can anyone understand what's happening
Thanks

## Data input
>date<-rep("2012/10/21", 14)
>hour<- c("00:02:38","00:11:05","00:19:33","00:28:00","00:36:27","00:44:57",
+"00:53:27","01:03:28","01:10:15","01:16:34","01:24:00","01:30:13","01:47:58",
+"01:52:43")
>time<-as.data.frame(cbind(date,hour))
# as.POSIXct formating
time$convert<-as.POSIXct(paste(time[,1],time[,2]),format="%Y/%m/%d
%H:%M:%S")
         date     hour             convert
1  2012/10/21 00:02:38                <NA>
2  2012/10/21 00:11:05                <NA>
3  2012/10/21 00:19:33                <NA>
4  2012/10/21 00:28:00                <NA>
5  2012/10/21 00:36:27                <NA>
6  2012/10/21 00:44:57                <NA>
7  2012/10/21 00:53:27                <NA>
8  2012/10/21 01:03:28 2012-10-21 01:03:28
9  2012/10/21 01:10:15 2012-10-21 01:10:15
10 2012/10/21 01:16:34 2012-10-21 01:16:34
11 2012/10/21 01:24:00 2012-10-21 01:24:00
12 2012/10/21 01:30:13 2012-10-21 01:30:13
13 2012/10/21 01:47:58 2012-10-21 01:47:58
14 2012/10/21 01:52:43 2012-10-21 01:52:43
## Se that the problem occur specifically with information concerning
21/oct/2012 between midnight and 1am

# alternatively strptime converting
>time$convert<-strptime(paste(time[,1],time[,2]),format="%Y/%m/%d %H:%M:%S")
>time$convert
         date     hour             convert
1  2012/10/21 00:02:38 2012-10-21 00:02:38
2  2012/10/21 00:11:05 2012-10-21 00:11:05
3  2012/10/21 00:19:33 2012-10-21 00:19:33
4  2012/10/21 00:28:00 2012-10-21 00:28:00
5  2012/10/21 00:36:27 2012-10-21 00:36:27
6  2012/10/21 00:44:57 2012-10-21 00:44:57
7  2012/10/21 00:53:27 2012-10-21 00:53:27
8  2012/10/21 01:03:28 2012-10-21 01:03:28
9  2012/10/21 01:10:15 2012-10-21 01:10:15
10 2012/10/21 01:16:34 2012-10-21 01:16:34
11 2012/10/21 01:24:00 2012-10-21 01:24:00
12 2012/10/21 01:30:13 2012-10-21 01:30:13
13 2012/10/21 01:47:58 2012-10-21 01:47:58
14 2012/10/21 01:52:43 2012-10-21 01:52:43
# seems ok, however try any further commands:
>range(time$convert)
[1] NA NA
>min(time$convert)
[1] NA
>time$convert[1] - time$convert[2]
Time difference of NA secs

 Just in case it helps my session information area
> sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Portuguese_Brazil.1252  LC_CTYPE=Portuguese_Brazil.1252
[3] LC_MONETARY=Portuguese_Brazil.1252 LC_NUMERIC=C
[5] LC_TIME=Portuguese_Brazil.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

loaded via a namespace (and not attached):
[1] grid_2.15.1    lattice_0.20-6 nlme_3.1-104



*Carlos André Zucco*
---------------------------------------------------------------------------------
Biólogo, Mestre em Ecologia
Laboratório de Ecologia e Conservação de Populações (LECP/IB/UFRJ)
Doutorando do Programa de Pós-graduação em Ecologia da UFRJ
---------------------------------------------------------------------------------

	[[alternative HTML version deleted]]

