Skip to content
Prev 12543 / 63461 Next

model.matrix(x ~ y) bug when y is array (PR#6838)

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: