Skip to content

Instantly share code, notes, and snippets.

@jonesor
Created November 6, 2018 10:45
Show Gist options
  • Save jonesor/cd1176e4ce5104f8869531ad99add368 to your computer and use it in GitHub Desktop.
Save jonesor/cd1176e4ce5104f8869531ad99add368 to your computer and use it in GitHub Desktop.
How to subset the COMPADRE/COMADRE matrix database based on the matrices themselves. This example counts NA values in the F matrix and uses that to subset.
#How to subset the matrix database based on the matrices themselves.
#This example counts NA values in the F matrix and uses that to subset.
nmat <- nrow(compadre$metadata)
for(i in 1:nmat){
compadre$metadata$NAinFmat[i] <- sum(is.na(compadre$mat[[i]]$matF))
}
table(compadre$metadata$NAinFmat)
x <- Rcompadre::subsetDB(compadre,NAinFmat == 0)
table(x$metadata$NAinFmat)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment