Plotting pca biplot with ggplot2

前端 未结 5 1120
粉色の甜心
粉色の甜心 2020-11-29 19:40

I wonder if it is possible to plot pca biplot results with ggplot2. Suppose if I want to display the following biplot results with ggplot2

fit <- princomp         


        
5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-29 20:11

    Here is the simplest way through ggbiplot:

    library(ggbiplot)
    fit <- princomp(USArrests, cor=TRUE)
    biplot(fit)
    

    enter image description here

    ggbiplot(fit, labels =  rownames(USArrests))
    

    enter image description here

提交回复
热议问题