r - PCA prcomp: how to get PC1 to PC3 graph -


in script pca (below), graph of pc1 vs pc2.

 mydata.pca <- prcomp(mydata.fixed, center = true, scale. = true)   g <- ggbiplot(mydata.pca, obs.scale = 1, var.scale = 1,                 groups = mysamples, ellipse = false,                 circle = false, var.axes=false)  g <- g + scale_color_discrete(name = '')  g <- g + theme(legend.direction ='horizontal',                  legend.position = 'top')  g <- g + theme_bw() 

however, when run like:

summary(mydata.pca) 

i see info pc1 pc4. how can change ggbioplot script graph of pc1 vs pc3?

the choices argument ggbiplot looking for:

iris_pca <- prcomp(iris[, 1:4], center = true, scale. = t)  # pc1 vs pc 2  ggbiplot(iris_pca, choices = c(1,2), obs.scale = 1, var.scale = 1,           groups = iris$species, ellipse = true,           circle = true) + scale_color_discrete(name = '') + theme(legend.direction = 'horizontal',                 legend.position = 'top') 

enter image description here

# pc1 vs pc 3  ggbiplot(iris_pca, choices = c(1,3), obs.scale = 1, var.scale = 1,           groups = iris$species, ellipse = true,           circle = true) + scale_color_discrete(name = '') + theme(legend.direction = 'horizontal',                 legend.position = 'top') 

enter image description here


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -