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

2005-08-02 Thread Sebastian Luque
Spencer Graves <[EMAIL PROTECTED]> wrote:
> How about the following:
>
>> set.seed(123)
>> mychron <- chron(sort(runif(10, 0, 10)))
>> (breaks <- chron(pretty(quantile(mychron
> [1] 01/01/70 01/03/70 01/05/70 01/07/70 01/09/70 01/11/70

I was looking for a way to cut it into specified units of time, rather
than quantiles. Anyway, both your suggestions show one can go very far
with the breaks arg.

Thank you!
-- 
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


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

2005-08-02 Thread Spencer Graves
How about the following:

 > set.seed(123)
 > mychron <- chron(sort(runif(10, 0, 10)))
 > (breaks <- chron(pretty(quantile(mychron
[1] 01/01/70 01/03/70 01/05/70 01/07/70 01/09/70 01/11/70
 >
spencer graves

Sebastian Luque wrote:

> Gabor Grothendieck <[EMAIL PROTECTED]> 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,

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com 
Tel:  408-938-4420
Fax: 408-280-7915

__
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


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

2005-08-02 Thread Sebastian Luque
Gabor Grothendieck <[EMAIL PROTECTED]> 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

__
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


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

2005-08-02 Thread Gabor Grothendieck
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)



On 8/2/05, Sebastian Luque <[EMAIL PROTECTED]> wrote:
> 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
>

__
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