File:Pca ggplot2.png

From 太極
Jump to navigation Jump to search

Original file(1,000 × 1,000 pixels, file size: 136 KB, MIME type: image/png)

Summary

df <- iris[, 1:4]  # exclude "Species" column

pca_res <- prcomp(df, scale = TRUE)

ggplot(iris, 
       aes(x = pca_res$x[,1], 
           y = pca_res$x[,2], 
           color = Species)) +
  geom_point() +
  stat_ellipse()

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current09:58, 23 May 2024Thumbnail for version as of 09:58, 23 May 20241,000 × 1,000 (136 KB)Brb (talk | contribs)<syntaxhighlight lang='r'> df <- iris[, 1:4] # exclude "Species" column pca_res <- prcomp(df, scale = TRUE) ggplot(iris, aes(x = pca_res$x[,1], y = pca_res$x[,2], color = Species)) + geom_point() + stat_ellipse() </syntaxhighlight>

The following page uses this file: