MomX / Momocs

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

PC rotate axes #152

Closed vbonhomme closed 7 years ago

vbonhomme commented 8 years ago

we need a method to flip PC axes, as known since long, and requested by Rachel Toczydlowski. Something like:

PCrotateaxis <- function(x, PC=1){
  if (missing(PCA)){
    x$x    <-  -1 * x$x
    x$mshape <-  -1 * x$mshape
    x$rotation <- -1 * x$rotation
  } else {
    x$x[, PC]    <-  -1 * x$x[, PC]
    x$mshape[PC] <-  -1 * x$mshape[PC]
    x$rotation[, PC] <- -1 * x$rotation[, PC]
  }
  x
}