Skip to content
Prev 58437 / 398502 Next

cut POSIX results in NA - bug?

Dear prof. Ripley

Thank you very much for explanation (without  it I would not 
consider include.lowest has something to do with my observation). 
I changed my code to get rid of single final POSIXdates.

BTW there is no mention in cut.POSIXt help page about 
include.lowest and  I think that in case of dates it does something 
what is maybe not so *understandable* (61 minutes in one hour). 

datum<-seq(ISOdate(2004,8,31), ISOdate(2004,9,1), "min")

# part of a datum variable
datum[1379:1381]
[1] "2004-09-01 12:58:00 St??edn\355 Evropa (letn\355 ??as)"   
"2004-09-01 12:59:00 St??edn\355 Evropa (letn\355 ??as)"  
[3] "2004-09-01 13:00:00 St??edn\355 Evropa (letn\355 ??as)"
# the last item seems to me to belong to time from 13:00:00 to 
13:59:00 e.g. it is part of thirteen's hour of a day

cut(datum[1370:1381],"hour", include.lowest=T) 
# it will include it to previous hour

 [1] 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00
 [7] 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00
Levels: 2004-09-01 12:00:00

 cut(datum[1370:1381],"hour")
# this will drop it from result, correct but unfortunate 

 [1] 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00
 [7] 2004-09-01 12:00:00 2004-09-01 12:00:00 2004-09-01 
12:00:00 2004-09-01 12:00:00 2004-09-01 12:00:00 <NA>               
Levels: 2004-09-01 12:00:00

# so as a result an hour can have 61 minutes
levels(cut(datum[1321:1381],"hour", include.lowest=T))
[1] "2004-09-01 12:00:00"

length(cut(datum[1321:1381],"hour", include.lowest=T)) #???
[1] 61

Is it correct?

Thank you again.

Best regards
Petr Pikal
On 3 Nov 2004 at 11:20, Prof Brian Ripley wrote:

            
Petr Pikal
petr.pikal at precheza.cz