'Is there a way to change the arrow types of a variable PCA plot using R?
I am using the factoextra package to plot a PCA and I have my variables and I coloured them by their contribution. However half of them are Temperature related and the other half are Precipitation, is there a way to manually make half of them with a dashed arrow line to distinguish them? (all the variables are active ones)
My data:
head(bioclim)
bio1 bio2 bio3 bio4 bio5 bio6 bio7 bio8 bio9 bio10 bio11 bio12 bio13 bio14 bio15 bio16 bio17 bio18 bio19
[1,] 47 71 22 8615 212 -102 314 142 -58 157 -64 622 80 27 33 224 92 219 106
[2,] 52 71 22 8494 215 -95 310 146 -15 160 -57 629 78 28 30 220 95 210 114
[3,] 51 70 22 8501 215 -97 312 146 -17 159 -58 616 79 28 32 220 92 213 107
[4,] 51 70 22 8501 215 -97 312 146 -17 159 -58 616 79 28 32 220 92 213 107
[5,] 50 66 22 8158 209 -91 300 109 -18 157 -52 669 78 32 30 224 105 201 136
[6,] 48 71 22 8690 217 -101 318 145 -57 160 -63 611 78 26 33 218 89 201 104
#PCA
res.pca <- prcomp(bioclim, scale = TRUE)
var.p <- fviz_pca_var(res.pca, col.var = "contrib", gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),repel = TRUE)
I also tried using a ggplot variant where the geom argument lets you change the arrows to points and show text but I am unable to make their lines dashed. Does anybody have a clue how to manually choose some variables and make their lines dashed? Or is this not possible at all?
ggpubr::ggpar(var.p, xlab= "PC1 (0.56)", ylab= "PC2 (0.18)", legend.title = "contribution", legend.position= "top", geom= c("arrow","point", "text"))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
