Beta
Table of Contents
The outline of your notebook will show up here. You can include headings in any text cell by starting a line with #
, ##
, ###
, etc., depending on the desired title hierarchy.
install.packages('PCAmixdata')
## Import library
library(PCAmixdata)
## Import data
df <- read.csv('https://github.com/nchelaru/data-prep/raw/master/telco_cleaned_renamed.csv')
## Split mixed dataset into quantitative and qualitative variables
## For now excluding the target variable "Churn", which will be added later as a supplementary variable
split <- splitmix(df[1:18])
## PCA
res.pcamix <- PCAmix(X.quanti=split$X.quanti,
X.quali=split$X.quali,
rename.level=TRUE,
graph=FALSE,
ndim=3)
## Inspect principal components
Proportion = res.pcamix$eig[1:5,2]
barplot(Proportion, main="Scree Plot",
xlab="Dimensions", ylab="Percentage of explained variance",ylim = c(0, 10))
a<- rbind(res.pcamix$quanti$contrib.pct, res.pcamix$quali$contrib.pct)
b <- sort(a[1:18,1])
contributions <- b[14:18]
cc <- data.frame(contributions)
cc
cc$variables <- row.names(cc)
#install ggplot2 and all dependencies
install.packages("ggplot2", dependencies=TRUE)
library(ggplot2)