I'm trying to output the rows of a matrix but I want to omit NaN and NAs. The following simple example illustrates:

```
 m <- matrix(c(1,2,NA,NaN,1,-1,-1,1,9,3),5)
for (i in 1:nrow(m)) { 
  cat(paste(sprintf('%d:%f', 1:ncol(m), m[i, ]), collapse=' '), "\n") 
 }

```

and the output is this:

```
1:1.000000 2:-1.000000 
1:2.000000 2:-1.000000 
1:NA 2:1.000000 
1:NaN 2:9.000000 
1:1.000000 2:3.000000 

```

but I want:

```
1:1.000000 2:-1.000000 
1:2.000000 2:-1.000000 
2:1.000000 
2:9.000000 
1:1.000000 2:3.000000 

```

I've been trying various combinations of `!is.na` but no joy. Can anyone help?