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

From: <zhuang_at_moho.ess.ucla.edu>
Date: Sun 16 Jul 2006 - 23:57:33 GMT


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.



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Mon Jul 17 10:00:14 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 Mon 17 Jul 2006 - 04:26:08 GMT.

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