Plotting PCA

https://cran.r-project.org/web/packages/ggfortify/vignettes/plot_pca.html

> install.packages("ggfortify")

> library(“ggfortify")


{ggfortify}let{ggplot2}know how to interpret PCA objects. After loading{ggfortify}, you can useggplot2::autoplot function for stats::prcomp and stats::princomp objects.

读入文件中的数据

> df<-read.csv("pom.csv",header=T)

> df

> autoplot(prcomp(df))       #出图

图形编辑

>help(autoplot.prcomp)

> autoplot(prcomp(df), data = df, colour = 'code')

> autoplot(prcomp(df), data = df, colour = 'code', label = TRUE, label.size = 3)

autoplot(prcomp(df), data = df, colour = 'code',

+  loadings = TRUE, loadings.colour = 'blue',

+ loadings.label = TRUE, loadings.label.size = 3)

你可能感兴趣的:(Plotting PCA)