From ripley at stats.ox.ac.uk  Thu Apr 29 12:12:45 2004
From: ripley at stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Thu Apr 29 12:12:49 2004
Subject: [Rd] Re: model.matrix(x ~ y) bug when y is array (PR#6838)
Message-ID: <20040429101245.86B4EEFCF@slim.kubism.ku.dk>

The underlying cause is that ncols(1D array) returns a random result,
often zero, so the term gets zero columns allocated in the model matrix
and a (long-existent) loop assums that columns is strictly positive.

I am putting in a check for zero columns, as well as repairing ncols which 
does

      t = getAttrib(s, R_DimSymbol);
      if (t == R_NilValue) return 1;
      return INTEGER(t)[1];

without any check on the length of t!

On Wed, 28 Apr 2004, Prof Brian Ripley wrote:

> I will tomorrow.  I want to know why it is happening before we guard 
> against whatever is the problem.
> 
> On Wed, 28 Apr 2004, Martin Maechler wrote:
> 
> > Is anybody actively looking into this?
> > 
> > If yes, I won't.
> > 
> > There are many places one could guard against the problem,
> > terms() being another possibility besides model.matrix.default()
> > or model.frame() or ...


-- 
Brian D. Ripley,                  ripley@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


[Rd] Re: model.matrix(x ~ y) bug when y is array (PR#6838)
ripley@stats.ox.ac.uk