-1
BK<- [1  2  3;   
      4  NA 6;   
      7  8  NA;  
      10 11 NA]  

How to remove rows containing NAs from column 2 without removing rows containing NAs from column 3 in R?

Many thanks!

Cine
  • 4,255
  • 26
  • 46
Brooke
  • 9

1 Answers1

0

Try this

BK[is.na(BK[,1:2])] <- 0
        [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    0    8
[3,]    3    6   NA

data

    BK <- matrix(c(1,2,3,4,NA,6,7,8,NA),3,3)
Arun kumar mahesh
  • 2,289
  • 2
  • 14
  • 22