Shannon Jasiel
Shannon Jasiel

Reputation: 11

R-Hiding/Deleting Vectors in my biplot with PCA

So I just want to be able to clearly see the points, and get rid of the vectors, because I am not interpreting those, here is my code:

FrogPCA <- prcomp(FrogData[,3:12], center=TRUE, scale=TRUE)

summary(FrogPCA)

biplot(FrogPCA, choices = c(1,2), col = c("magenta3", "slateblue3" ))

Any help is appreciated!

Upvotes: 0

Views: 1023

Answers (3)

Shivkumar VS
Shivkumar VS

Reputation: 11

Late to the party, but including var.axes=0 should work

Upvotes: 1

Maurits Evers
Maurits Evers

Reputation: 50668

Here is an example how to re-produce the biplot output without the unscaled axes (i.e. the red arrows), based on the USAarrests dataset (unfortunately you don't provide data).

pca <- prcomp(USArrests, scale = TRUE)

plot(pca$x[, "PC1"], pca$x[, "PC2"], type = "n", xlab = "PC1", ylab = "PC2")
text(pca$x[, "PC1"], pca$x[, "PC2"], rownames(pca$x))

enter image description here

Upvotes: 2

Santiago Capobianco
Santiago Capobianco

Reputation: 886

How about this (the example is with iris):

> data(iris)
> #iris
> 
> IrisPCA <- prcomp(iris[, 1:3], center = TRUE, scale = TRUE)
> table(iris$Species)

    setosa versicolor  virginica 
        50         50         50 
> 
> plot(IrisPCA$x, col = c(rep("red", 50), rep("green", 50), rep("blue", 50)))

enter image description here

There is package called plot3D that can perform the same in 3 dimensions. If its usefull I can edit later.

Hope it helps.

Upvotes: 2

Related Questions