Frage

I wish query a matrix object and return a simple TRUE/FALSE answer if a matrix contains any NAs. So, if there are no NAs present you would get FALSE.

is.na(my.matrix) will tell me element-by-element if NAs are present, but I don't know how to sum up the results into a single answer. na.fail() looks like a better bet, but I'm still not sure how to extract a straightforward TRUE/FALSE answer.

War es hilfreich?

Lösung

As Ananda Mahto pointed out, any(is.na(my.matrix)) does the trick.

Andere Tipps

If you want to find the number of occurrences of NA then try sum(is.na(my.matrix)).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top