0

I wanna use PCA but I can not plot it! I run PCA successfully using packege and following code:

  pc<-prcomp(C, scale = FALSE)
  summary(pc) 

then for plot I used

   library(devtools)
   install_github("vqv/ggbiplot")
   library(ggbiplot)
   ggbiplot(pc)

But I get this error:

   Error in names(df.v) <- names(df.u) : 
   'names' attribute [2] must be the same length as the vector [1]
  • Keep in mind that we have neither your data nor your output, so we can't run your code and we can't see what's happening. It will be easier to help with a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) – camille Jul 17 '19 at 16:32

1 Answers1

-1

I typically use ggplot for my PCA plotting needs, as it allows me to overlay metadata by color/shape coding.

My typical code for a basic PCA is just:

    library(ggfortify)
    library(ggrepel)
    library(GGally)
    library(gplots)
    library(ggplot2)
    x <- prcomp(y)
    autoplot(x) + #any color/shape/text edits you want to make

This code was passed down to me by someone I work with, but I've not had any issues with it.

Bern
  • 1
  • 2