I am trying to plot the first two columns against each other of a matrix Y, and assigning different data points different shapes and colors according to which group they belong to in the 12th column of my data set. Below is my code:
X <- as.matrix(course[,1:11])
S <- cov(X)
l <- eigen(S)$values
e <- eigen(S)$vector
Y <- X %*% e
plot(Y[,1:2],
xlab = "PC1",
ylab = "PC2",
pch = c(1, 17, 8)[as.numeric(course[,12])], # different 'pch' types
main = "Plot of first 2 Principle Components",
col = c(1, 8, 1)[as.numeric(course[,12])]
)
"course" is the data set I'm working with, and Y is the matrix i'm interested in using for my plot. However one of the groups which i'm basing my labeling on is basically missing values or "NA". I can't use as.numeric() since this does not treat "NA" values as numeric.
When i run the code from the plot, I get two set of values, and it completely ignores the ones for NA.
I would really appreciate the help.