options(repos = c(CRAN = "https://cloud.r-project.org"))
#Packages to install
install.packages("psych")
## Installing package into 'C:/Users/geral/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'psych' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\geral\AppData\Local\Temp\RtmpQDY8kQ\downloaded_packages
install.packages("GPArotation")
## Installing package into 'C:/Users/geral/AppData/Local/R/win-library/4.5'
## (as 'lib' is unspecified)
## package 'GPArotation' successfully unpacked and MD5 sums checked
## 
## The downloaded binary packages are in
##  C:\Users\geral\AppData\Local\Temp\RtmpQDY8kQ\downloaded_packages
library("psych")
library("GPArotation")
## 
## Attaching package: 'GPArotation'
## The following objects are masked from 'package:psych':
## 
##     equamax, varimin
#Getting the data into R
Data <- read.csv(file.choose(),header=T)
attach(Data)
names(Data)
##  [1] "Obs"                           "Form.of.letter.of.application"
##  [3] "Appearance"                    "Academic.ability"             
##  [5] "Likeability"                   "Self.confidence"              
##  [7] "Lucidity"                      "Honesty"                      
##  [9] "Salesmanship"                  "Experience"                   
## [11] "Drive"                         "Ambition"                     
## [13] "Grasp"                         "Potential"                    
## [15] "Keeness.to.join"               "Suitability"
options(scipen = 999)
#Overall Raw Score – determine top 3
Data$OverallRaw <- Form.of.letter.of.application + Appearance + Academic.ability +
  Likeability + Self.confidence + Lucidity + Honesty + Salesmanship + Experience + Drive +
  Ambition + Grasp + Potential + Keeness.to.join + Suitability
#Create data frame with assignment 2 variables
DataFrame <- Data[, c("Form.of.letter.of.application", "Appearance", "Academic.ability", "Likeability",
                      "Self.confidence", "Lucidity", "Honesty", "Salesmanship", "Experience", "Drive", "Ambition", "Grasp", "Potential",
                      "Keeness.to.join", "Suitability")]
#Scree Plot
ScreePlot <- scree(DataFrame, factors = TRUE, main = "Scree plot", hline = NULL, add = FALSE)

#Eigen Values Total Variance Explained
ev <- eigen(cor(DataFrame))
summary(ev)
##         Length Class  Mode   
## values   15    -none- numeric
## vectors 225    -none- numeric
ev$values
##  [1] 7.51379418 2.05630117 1.45581948 1.19789771 0.73915262 0.49457907
##  [7] 0.35126183 0.30990202 0.25696154 0.18491037 0.15268036 0.09756308
## [13] 0.08881880 0.06463323 0.03572455
cumsum(ev$values)/15
##  [1] 0.5009196 0.6380064 0.7350610 0.8149208 0.8641977 0.8971696 0.9205871
##  [8] 0.9412472 0.9583780 0.9707053 0.9808840 0.9873882 0.9933095 0.9976184
## [15] 1.0000000