[R] cut.Date functionality for chron date/time objects

Sebastian Luque spluque at gmail.com
Wed Aug 3 02:55:34 CEST 2005


Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
> Assuming, as in your post:
>
> set.seed(123)
> mychron <- chron(sort(runif(10, 0, 10)))
> breaks <- quantile(mychron)
>
> # is one of these adequate?
>
> cut(mychron, breaks)
>
> cut(unclass(mychron), unclass(breaks), lab = FALSE)

Thank you Gabor, that showed me I really needed to be more creative with
the 'breaks' argument. So what I needed was (with mychron as above):

breaks <- seq(min(mychron, na.rm = TRUE),
              ceiling(max(mychron, na.rm = TRUE)), by = 1/2)

cut(unclass(mychron), unclass(breaks),
    include.lowest = TRUE, labels = FALSE)


in order to cut the chron object into 1/2 day units.


Thanks so much,
-- 
Sebastian P. Luque




More information about the R-help mailing list