MomX / Momocs

:dove: Morphometrics using R
http://momx.github.io/Momocs/
51 stars 18 forks source link

breed fac-wise #180

Closed vbonhomme closed 6 years ago

vbonhomme commented 7 years ago

so far you can still :

# breed group wise
x2 <- x %>% chop(taxa) %>% lapply(breed, 500) 
# retrieves all matrices of coefficients and rbind them
coes <- lapply(x2, function(.) `$`(., coe)) %>% do.call("rbind", .)
# creates a single column $fac for all Coes in the list
facs <- for (i in seq_along(x2)){
  x2[[i]]$fac <- data.frame(group=rep(names(x2)[i], length(x2[[i]])))
}
# retrieves all $fac (freshly created) and rbind them
facs <- lapply(x2, function(.) `$`(., fac)) %>% do.call("rbind", .)
final <- x2[[1]] # final OutCoe shoudl looks like any other Coes in the list
final$coe <- coes
final$fac <- facs
final %>% PCA %>% plot(~group, chull.filled=T, ellipsesax=F)