Skip to content

dates in chron package, split warning message

3 messages · Steve Su, Brian Ripley

#
the
messages
****************************************************************************
****************************************************************************
****************************************************************************
****************************************************************************
#
On Thu, 22 May 2003, Steve Su wrote:

            
The dates function (not command) does work of course.  It's cut.dates
which fails.  The short answer to you is this is a great opportunity to
learn to debug R functions, and the hint is that the line

    from <- switch(by, days = from, 
	weeks = (from - day.of.week(mdy$m,mdy$d, mdy$y) + as.numeric(start.on.monday)), 
        months = chron(julian(mdy$m, 1, mdy$y, origin = orig)),
        years = chron(julian(1, 1,mdy$y, origin = orig)))

contains two bugs.
Try reading the help pages in each system.  They do not define split in 
the same way, and your usage is incorrect in R but not in S-PLUS 6.1.
#
Dear All,

Thank you Professor Ripley for your prompt and helpful reply.

I propose the answer to my question on cut.dates function is do the
following:

months = chron(julian(mdy$m,
1, mdy$y, origin = orig),origin=orig)-1, years = chron(julian(1, 1,
mdy$y, origin = orig),origin=orig)-1)

in the cut.dates function.

As to my second query, I modify the split function by adding the following
line in the split.default function:

if(is.matrix(x)){
return(.Internal(split(c(x),factor(rep(f,length=length(c(x)))))))

which works well for my needs.

Thank you for your attention.

Steve.





----- Original Message -----
From: "Prof Brian Ripley" <ripley at stats.ox.ac.uk>
To: "Steve Su" <s.su at qut.edu.au>
Cc: "R Help" <r-help at stat.math.ethz.ch>
Sent: Thursday, May 22, 2003 4:44 PM
Subject: Re: [R] Re: dates in chron package, split warning message
in
as.numeric(start.on.monday)),
do.