Skip to content

Instantly share code, notes, and snippets.

@mhoangvslev
Created November 5, 2019 22:27
Show Gist options
  • Save mhoangvslev/03589883d6681a0bf052f3e8d06f26e1 to your computer and use it in GitHub Desktop.
Save mhoangvslev/03589883d6681a0bf052f3e8d06f26e1 to your computer and use it in GitHub Desktop.
Contribution des invidivus
# Individus
## Contribution relative
result$ind$qlt <- matrix(unlist(lapply(1:nbIndv, function(indv){
(result$ind$coords[indv, ]**2) / sum(result$ind$coords[indv, ]**2)
})), nrow = nbIndv, ncol = nbComps, byrow = TRUE);
colnames(result$ind$qlt) <- colnames(result$ind$qlt, do.NULL = FALSE, prefix = "Comp. ");
## Contribution absolue
result$ind$ctr <- matrix(unlist(lapply(1:nbComps, function(axe){
result$ind$coords[, axe]**2 / (nbIndv * eigenvalues[axe])
})), nrow = nbIndv, ncol = nbComps);
colnames(result$ind$ctr) <- colnames(result$ind$ctr, do.NULL = FALSE, prefix = "Comp. ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment