Dear R user I have data created using code below
b<-matrix(2:21,nrow=4) b[,1:3]=NA b[4,2]=5 b[3,1]=6 Now the data is > b [,1] [,2] [,3] [,4] [,5] [1,] NA NA NA 14 18 [2,] NA NA NA 15 19 [3,] 6 NA NA 16 20 [4,] NA 5 NA 17 21 I want to keep data in column 4 greater than 15 and the value in column 1 & 2 either greater than 4 or is 'NA'. So I would like to have my outcome as below... [3,] 6 NA NA 16 20 [4,] NA 5 NA 17 21 I thought something like the code below gonna to work but it only returns the last row,e.g "NA 5 NA 17 21". ... bb<-b[which( (b[,2]>4 | b[,2]==NA) & (b[,1]>4 | b[,1]==NA) & b[,4]>15) ,]) Please could anyone help? Many thanks in advance HJ [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.