## load packages library("gclus") library("stats") library("cluster") library("clusterSim") # set working directory for module and check setwd("C:/Users/ufrei/Desktop/WD-module") getwd() #load the MeanMeanEarPhenotypes dataset and look at the structure data <- read.csv("MeanMeanEarPhenotypes.csv", header = T) str(data) #subsetting dataset to 5 variables #datap <- subset(data, select=c("RowNo.","EarDM","EarL", "CobWt", "ca300KWt" )) datap <-subset(data, select= -(Pedigree:Type) # and data standardization PCAdata <-data.Normalization(datap, type="n1") cpairs(PCAdata) PCA2 <- prcomp(PCAdata, center=T, scale=T) class(PCA2) ls(PCA2) summary(PCA2) #calculate Eigen values for each component: square of standard deviation PCA2$sdev^2 # Graphical display screeplot(PCA2, type="line", main="Scree Plot") #graphical display: biplot(PCA2,cex =c(1, 0.7) ) biplot(PCA2,cex =c(1, 0.7),xlabs=data$Type ) var <- varimax(PCA2$rotation) var