data(carnivora)
matrices <- phylter(carnivora, InitialOnly = TRUE, parallel = FALSE)$matrices
# remove n species randomly (n between 1 and 5) in each matrix (to mimic missing data)
fun<-function(mat) {
species2remove<-sample(1:nrow(mat),sample(1:5,1))
mat<-mat[-species2remove,-species2remove]
return(mat)
}
matrices.missing<-lapply(matrices, fun)
#check that all matrices have now different dimensions:
lapply(matrices.missing, dim)
# Impute data to get back to the same dimensions
matrices.ok<-impMean(matrices.missing)
lapply(matrices.ok, dim) #all dimensions are now identical. Missing data have been imputed.
Run the code above in your browser using DataLab