Search code examples
rplotpca

How to determine the observations when they are mashed for a PCA plot


I've done a PCA with R using the function princomp and the ggfortify package. I cannot determine the all the observations at the 4th component (where there is an X25 and 2-4 other observations). Is there a way for me to do this more smoothly where I can distinguish them? I don't care what package to use, I'd just like to see what the observations are much better.

enter image description here


Solution

  • You can use label.repel=TRUE from the ggfortify package.

    An example using the mtcars dataset:

    Overlapping labels:

    autoplot(prcomp(mtcars),
                      label=T)
    

    enter image description here

    Repelled labels:

    autoplot(prcomp(mtcars),
             label=T,label.repel=T)
    

    enter image description here