Search code examples
rpca

arrow type FactoMineR


I've used the 'PCA' function from the 'FactoMineR' package to obtain principal component scores. I've tried reading through the package details and similar questions on this forum but can't figure out the code to modify the line type of the arrows used to represent supplementary variables on the variables factor map. By default, these are blue and dashed lines and I desperately cannot find how to make them continuous

I don't manage ggplot and really want to know if there is a solution to this kind of plot :

plot(res, choix="var")

Does someone know the tip please ?

For example, here is a code :

library(FactoMineR)
data("decathlon")
res <- PCA(decathlon,quanti.sup = 10:12,quali.sup = 13) #this would generate an automatic plot but I'd prefer working on a personal plot
windows()
plot(res,choix="var", shadow = T, title="", cex = 1.2, cex.lab = 1.3)

Solution

  • The dashed line parameter is hard-coded, so you can't alter it when calling the function. Here is the exact line of code the function is calling:

    arrows(0, 0, coord.quanti[q, 1], coord.quanti[q, 2], length = 0.1, angle = 15, code = 2, lty = 2, col=coll2[q])
    

    If you need to change it, you would have to get the code from github and change lty=2 to lty=1 on line 350 (shown above), or just make it an optional input parameter to the function and set lty to the variable value. Then, you would call plot.PCA(res,choix="var", shadow = T, title="", cex = 1.2, cex.lab = 1.3)

    enter image description here