R-alpha: more little problems

Thomas Lumley (thomas@biostat.washington.edu)
Fri, 20 Sep 1996 11:08:38 -0700 (PDT)

```Date: Fri, 20 Sep 1996 11:08:38 -0700 (PDT)
From: Thomas Lumley <thomas@biostat.washington.edu>
To: r-testers@stat.math.ethz.ch
Subject: R-alpha: more little problems

1. pmin and pmax coerce matrices to vectors.  This is incompatible with S.
The documentation says they work on vectors, and as is.vector() returns
TRUE for a matrix it is not completely unreasonable that they should work on
matrices. It's also massively useful. A first pass at fixing this is to
make the following insertions near the end of pmax and pmin respectively:

pmax:
-----------------------------
maxmm <- work[, 1]
}
attributes(maxmm)<-attributes(elts[[1]])  ###insert
maxmm
}
-----------------------------
pmin:
-----------------------------
minmm <- work[, 1]
}
attributes(minmm)<-attributes(elts[[1]]) ###insert
minmm
}
----------------------------
Of course ideally we should check that all the dimensions are either the
same or NULL.

2. model.matrix(formula, data) does not use the names of the data frame it
is passed (unlike in S). It assumes that the variables in the formula
start at column 1 of the data frame and proceed in order.  This works
correctly in the standard situation when data comes from
model.frame(formula) but can be a problem if the data frame was
constructed in some other way.  In particular if the data frame has a
response and the formula does not, you will get the wrong answer with no
error message.  Other manipulations of a formula have the same
implications.

thomas lumley       Penguin: the name is supposed to come from
PhD student         the Welsh _pen_gwyn_ meaning "white head".
Biostatistics       As penguins have black heads and do not live
U. Washington       within 10000 miles of Wales it is difficult
Seattle WA 98195    to see how this theory arose.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
r-testers mailing list -- To (un)subscribe, send
subscribe	or	unsubscribe
(in the "body", not the subject !)  To: r-testers-request@stat.math.ethz.ch
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
```