[R] matrix selection return types

From: <vincent_at_7d4.com>
Date: Thu 15 Jun 2006 - 23:41:14 EST


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 Received on Thu Jun 15 23:46:58 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 16 Jun 2006 - 04:12:57 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.