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

From: Sebastian Luque <spluque_at_gmail.com>
Date: Wed 03 Aug 2005 - 06:17:50 EST


Hello,

I've encountered the need to cut some chron objects of the form:

R> mychron <- chron(sort(runif(10, 0, 10))) R> mychron

 [1] (01/01/70 16:36:20) (01/02/70 00:08:46) (01/03/70 16:54:49)
 [4] (01/04/70 06:45:00) (01/07/70 06:21:24) (01/07/70 18:28:44)
 [7] (01/08/70 00:47:05) (01/08/70 05:11:44) (01/10/70 01:07:53)
[10] (01/10/70 17:46:53)

into arbitrary (e.g. a given number of minutes, seconds, etc.) units. Basically, I'm searching for the functionality of cut.Date, which has a nice 'breaks' argument:

,-----[ *help[R](cut.Date)* (lines: 23 - 30) ]
| breaks: a vector of cut points _or_ number giving the number of
| intervals which 'x' is to be cut into _or_ an interval
| specification, one of '"sec"', '"min"', '"hour"', '"day"',
| '"DSTday"', '"week"', '"month"' or '"year"', optionally
| preceded by an integer and a space, or followed by '"s"'.
| For '"Date"' objects only '"day"', '"week"', '"month"' and
| '"year"' are allowed.

`-----

'cut.dates' (from chron itself) allows for cut'ing into months, years, etc., but not any fractions or multiples of these.

Converting the chron objects to POSIXct (via 'as.POSIXct') and then using cut.Date works, but is inconvenient, as it introduces time zone information. Is there a better way to deal with this?

Thanks in advance,

-- 
Sebastian P. Luque

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Aug 03 06:32:42 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:39:39 EST