Skip to content

Instantly share code, notes, and snippets.

@njtierney
Created September 5, 2016 06:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njtierney/e6d481fbfefcd3f5f03eb04dff1878aa to your computer and use it in GitHub Desktop.
Save njtierney/e6d481fbfefcd3f5f03eb04dff1878aa to your computer and use it in GitHub Desktop.
find if a matrix contains only missing values
ras_1 <- matrix(data = rep(NA, 100),
nrow = 10,
ncol = 10,
byrow = TRUE)
ras_1
ras_2 <- matrix(data = c(1,rep(NA, 99)),
nrow = 10,
ncol = 10,
byrow = TRUE)
ras_2
all(is.na(ras_1))
all(is.na(ras_2))
all_na <- function(x) all(is.na(x))
all_na(ras_1)
all_na(ras_2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment