When I plot a PCA and then the corresponding biplot, the axis are not always in the same direction, just like in these pictures:
These are the functions, I used:
(pc <- prcomp(dat5, center=T, retx=T, scale=T)); summary(pc)
plot(pc$x[,1:2], pch=""); text(pc$x[,1:2], cex=.5, labels=(row.names(dat5)), col=as.numeric(dat$ObCl))
biplot(princomp(dat5, cor=T), cex=.5)
How can I change the axis direction of one of those, to make them the same?
The sign of PCs being arbitrary, you can change it/them by multiplying one or more PCs by -1. Note that this stands only for representation only, depending on what you do, eg if you use
$rotation
you may also need to change the corresponding columns as well. An example withiris
follows. Hope this helps.