[R] matrix

Bill Venables venables at acland.qld.cmis.csiro.au
Mon Apr 24 03:13:53 CEST 2000


Göran Broström writes:
> 
> Thanks to Brian Ripley and Peter Dalgaard for quick replies. The argument
> 'drop = F' does the trick, as in
> 
> > is.matrix(x[1:2, , drop = F]) 
> [1] TRUE
> 
> However, the real issue, why a subset of a matrix is not (necessarily)
> a matrix, is apparently a matter of  S  compatibility.

Hmm.  Yes and no.  There comes a time when you realise that this
is a very useful convenience for interactive users but a real
curse for programmers.  As most users of R are interactive users,
on the whole it pays off, as it does in the progenitor system.

It takes a very long time for programmers to remember when to put
"drop = T" in extraction function calls (well, for me at least,
because it has not come yet!).  It is also very easy *not* to be
aware of the number of times the convention has saved people from
getting some very obscure and puzzling error messages.

I think the Matrix class of S is an instructive example.  Objects
of class "Matrix" behave just like matrices but have some
considerable advantages and also are ruthlessly logical in not
honouring this drop convention.  The Matrix library is well
documented and available on all systems, but as far as I can tell
almost no one has even heard of it, let alone uses it.  It's a
real pity in a way since it does offer real programming
advantages, but that's how it is.  Moreover I detect no great
clamour from users for something similar available in R.  (This
may be partly because Brian would tell them to "go and write the
jolly thing yourself it you really want it", but only partly!)


-- 
Bill Venables,      Statistician,     CMIS Environmetrics Project
CSIRO Marine Labs, PO Box 120, Cleveland, Qld,  AUSTRALIA.   4163
Tel: +61 7 3826 7251           Email: Bill.Venables at cmis.csiro.au    
Fax: +61 7 3826 7304      http://www.cmis.csiro.au/bill.venables/



-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list