[R] cut.POSIXct problem

Petr Pikal petr.pikal at precheza.cz
Tue Jun 17 11:07:52 CEST 2003


Dear all

I would like to aggregate a data frame in a three minute interval. I have a time 
vector:

> str(cas.param)
`POSIXct', format: chr [1:181] "2003-06-12 09:00:00" "2003-06-12 09:01:00" 
"2003-06-12 09:02:00" 

and I want to turn it into a factor by cut. It works if I want to break it in let say 
hours

> str(cut(cas.param,breaks="hour"))
 Factor w/ 3 levels "2003-06-12 ..",..: 1 1 1 1 1 1 1 1 1 1 .

But if i tried to do similar task but to construct three minutes intervals with a 
vector of cut points it gives me an error

> cut(cas.param,breaks=seq(min(cas.param),max(cas.param), by="3 mins"))
Error in sort(breaks) : `x' must be atomic

however

> str(seq(min(cas.param),max(cas.param), by="3 mins"))
`POSIXct', format: chr [1:61] "2003-06-12 09:00:00" "2003-06-12 09:03:00" 
"2003-06-12 09:06:00"

works.

So it is definitely my lack of understanding how to implement a vector of cut 
points (constructed by seq()), to break parameter of cut() function.

Please can you give me any hints?

R 1.7.0, Windows NT

Thanks a lot

Petr Pikal
petr.pikal at precheza.cz
p.pik at volny.cz




More information about the R-help mailing list