> m = matrix(1:6 , 2 , 3)
> ?'['
> z1 <- m[m[,1] == 2,]
> z1
[1] 2 4 6
> is.matrix(z1)
[1] FALSE
> z1 <- m[m[,1] == 2,, drop=FALSE]
> z1
     [,1] [,2] [,3]
[1,]    2    4    6
> is.matrix(z1)
[1] TRUE
>


On 6/15/06, vincent@7d4.com <vincent@7d4.com> wrote:
>
> Dear Rusers,
>
> I would like some comments about the following results
> (under R-2.2.0)
>
> > m = matrix(1:6 , 2 , 3)
> > m
>      [,1] [,2] [,3]
> [1,]    1    3    5
> [2,]    2    4    6
>
> > z1 = m[(m[,1]==2),]
> > z1
> [1] 2 4 6
> > is.matrix(z1)
> [1] FALSE
>
> > z2 = m[(m[,1]==0),]
> > z2
>      [,1] [,2] [,3]
> > is.matrix(z2)
> [1] TRUE
>
> Considered together, I'm a bit surprised about the
> returned types from z1 and z2.
> I would not have been surprised if z1 would still
> have been a matrix, or z2=NULL.
>
> There is certainly a logic behind this choice
> but it's not very clear for me,
> so any help/comment appreciated.
>
> Thanks
> Vincent
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390 (Cell)
+1 513 247 0281 (Home)

What is the problem you are trying to solve?

	[[alternative HTML version deleted]]

