Skip to content

Instantly share code, notes, and snippets.

@jonesor
Created August 6, 2015 14:15
Show Gist options
  • Save jonesor/edefb525c027d970085b to your computer and use it in GitHub Desktop.
Save jonesor/edefb525c027d970085b to your computer and use it in GitHub Desktop.
How to subset COMADRE Animal Matrix Database
#How to subset the COMADRE Animal Matrix Database (works with COMPADRE too)
#Create a vector of indices to retain
subsetID <- which(comadre$metadata$Order %in% c("Monotremata","Didelphimorphia","Paucituberculata","Microbiotheria","Dasyurormorphia","Peramelemorphia","Diprotodontia"))
#Subset entire COMADRE object to JUST the above subset
#First make a copy
subset.comadre <- comadre
#Now subset the sub-parts of the database
#metadata
subset.comadre$metadata <- mammal.comadre$metadata[subsetID,]
#matrices
subset.comadre$mat <- mammal.comadre$mat[subsetID]
#matrix class information
subset.comadre$matmatrixClass <- mammal.comadre$matrixClass[subsetID]
@jonesor
Copy link
Author

jonesor commented Nov 6, 2018

This is now superceded by the subsetDB function in the Rcompadre package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment