I struggled with changing the length of loads (arrows) in ggplot2 / ggfortify PCA. I examined this answer in detail, and the only information I found was either with the new biplot features or with other completely different PCA packages (ggbiplot, factoextra), none of which relate to the question I would like to answer:
Is it possible to scale / resize PCA downloads in ggfortify?
Below is the code I have to build for the PCA using the R functions, as well as the code for building the PCA using autoplot / ggfortify. You will notice that on the stock exchanges of R I can scale the load just by multiplying by the scalar (* 20 here), so my arrows are not limited in the middle of the PCA chart. Using autoplot ... not so much. What am I missing? I will move on to another package if necessary, but I would really like to better understand ggfortify.
On other sites that I found, the axes of the graph never exceed +/- 2. My graph is +/- 20, and the loads sit firmly around 0, presumably on the same scale as the graphs with smaller axes. I would still like to draw a PCA using ggplot2, but if ggfortify does not, I need to find another package that will be.
georoc <- read.csv("http://people.ucsc.edu/~mclapham/earth125/data/georoc.csv")
library(ggplot2)
library(ggfortify)
geo.na <- na.omit(georoc)
geo_matrix <- as.matrix(geo.na[,3:29])
pca.res <- prcomp(geo_matrix, scale = T)
summary(pca.res)
plot(pca.res$x, col = c("salmon","olivedrab","cadetblue3","purple")[geo.na$rock.type], pch = 16, cex = 0.2)
legend("topleft", c("Andesite","Basalt","Dacite","Rhyolite"),
col = c("salmon","olivedrab","cadetblue3","purple"), pch = 16, bty = "n")
arrows(0, 0, pca.res$rotation[,1]*20, pca.res$rotation[,2]*20, length = 0.1)
text(pca.res$rotation[,1]*22, pca.res$rotation[,2]*22, rownames(pca.res$rotation), cex = 0.7)
autoplot(pca.res, data = geo.na, colour = "rock.type",
loadings = T, loadings.colour = "black", loadings.label = T,
loadings.label.colour = "black")
, , , ggplot2 ggfortify. .
R- , , ggplot
ggplot