[Rd] subsetting a matrix by conditions (PR#9082)

zhuang at moho.ess.ucla.edu zhuang at moho.ess.ucla.edu
Mon Jul 17 01:57:33 CEST 2006


Full_Name: Jiancang Zhuang
Version: 2.3.0
OS: Windows XP, BSD, Linux
Submission from: (NULL) (130.195.2.100)


> a<-matrix(scan(), ncol=3, byrow=T)
1: 6 NA 4 
4: 5 3 6
7: 8 2 9 
10: 3 6 NA
13: 
Read 12 items
> a
     [,1] [,2] [,3]
[1,]    6   NA    4
[2,]    5    3    6
[3,]    8    2    9
[4,]    3    6   NA
> a[a[,2]>2,]
     [,1] [,2] [,3]
[1,]   NA   NA   NA
[2,]    5    3    6
[3,]    3    6   NA

We may hope the first row of A removed or keep the same. However, R keeps the
first row and changes all the value in that row into NA.



More information about the R-devel mailing list