[R] matrix

gb gb at stat.umu.se
Sun Apr 23 22:02:37 CEST 2000


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.

> On Sun, 23 Apr 2000, gb wrote:
> 
> > 
> > Is there a reason for the following behaviour?
> > 
> > > x <- matrix(1:6, ncol = 1)
> > > x
> >      [,1]
> > [1,]    1
> > [2,]    2
> > [3,]    3
> > [4,]    4
> > [5,]    5
> > [6,]    6
> > > is.matrix(x)
> > [1] TRUE
> > > is.matrix(x[1:2,])
> > [1] FALSE

Göran
----------------------------------------------------------
 Göran Broström, professor           tel: +46 90 786 5223
 Department of Statistics            fax: +46 90 786 6614
 Umea University
 SE-90187 Umea, Sweden            e-mail: gb at stat.umu.se
----------------------------------------------------------

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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