First Chapter

DSC DSC DSC DSC DSC DSC DSC

getwd()
[1] "C:/Users/htchu/Documents"
setwd("D:/5R")
getwd()
[1] "D:/5R"
data <- read.table("constitution3.csv", header = TRUE, sep = ",", encoding = "big5")
features<-data[,6:ncol(data)]
genders<-data[,3]
pca <- prcomp(features,
              center = FALSE,
              scale. = FALSE) 
# print method
print(pca)
# plot method
plot(pca, type = "l")
# summary method
summary(pca)
g <- ggbiplot(pca, obs.scale = 1, var.scale = 1, 
              groups = genders, ellipse = TRUE, 
              circle = TRUE)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal', 
               legend.position = 'top')
print(g)

results matching ""

    No results matching ""