Hello All,
I've made the following PCA graph (first attachment), but, I'd like to modify it further and I have some things I want to show while keeping the current look (colors of each points, legend, etc.)
I'm attempting to show vectors such as in another plot I've made (second attachment) and also have the points labeled with the names in the legend from the first plot.
Here is the code I've used to this point:
library(reshape2)
library(ggplot2)
library(grid)
# Load in the Data #
hapfreq <-read.csv('Hapfreq4.csv', header=T)
hapfreq
#Subset for PCA#
hgf<-subset(hapfreq, select=C:K)
hgf
#Run the PCA#
pca <- prcomp(hgf, scale=T)
summary (pca)
pca
###Graphing the PCA####
# This is the hard part. Going to try using the ggplot2 library###
scores <- data.frame(hgf, pca$x[,1:2])
scores
hapfreq2 <-read.csv('abb1.csv', header=T)
hapfreq3 <-read.csv('HGs.csv', header=T)
jphg <- data.frame(scores, hapfreq2)
jphg
pcaplot <- qplot(x=PC1, y=PC2, data=jphg, colour=factor(abbr.))
pcaplot
Hopefully this makes sense. Let me know if you have questions and thanks in advance for the help.