[R] Re: dates in chron package, split warning message

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu May 22 08:44:51 CEST 2003


On Thu, 22 May 2003, Steve Su wrote:

> > > I am currently using R for windows.
> > >
> > > I am wondering why the dates command in chron package does not work in
> the
> > > following situation:
> > >
> > > cut(dates(c(23,45,67),origin=c(1,1,2004)),"months")
> > >
> > > but will work for:
> > >
> > > cut(dates(c(23,45,67),origin=c(1,1,2004)),"days")
> > > cut(dates(c(23,45,67),origin=c(1,1,2004)),"weeks")

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.

> > > My second query is rather trivial but I am wondering why warning
> messages
> > > were given when using the split in this manner:
> > >
> > > split(matrix(1:12,nrow=4),c(1,1,2,3)) # Which does what I want it to do.
> > >
> > > and no warning messages were given in Splus6 for example?

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.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list