SHARE
TWEET

Untitled

a guest Sep 27th, 2017 258 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Clients matrix with data from clientes.txt file
  2. PATH= "Desktop/Business Intelligence/Tareas/Tarea 2/clientes.txt"
  3. clients=read.table(PATH, sep = " ")
  4. #Matrix with only 15 first columns of the original matrix
  5. names <- c("ClientSubtype", "HouseNum", "HouseInhabitantsNum", "AvgAge", "ClientType", "Religion", "CivilState", "FamilyType", "ScholarEducation", "JobType", "SocialClass", "HouseType", "CarsNum", "HealthType", "AvgIncome")
  6. M<-clients[,1:15]
  7. colnames(M) <- names
  8.  
  9. #Exercise 1 - Find relevant variables
  10. stdM <- scale(M)
  11. corM <- cor(stdM)
  12. varM <- apply(M, 2, var)
  13.  
  14. #Remove variables and transform data into categorical values
  15. M$ClientSubtype<-NULL #"ClientSubType" was removed due to its high correlation with "ClientType"
  16. M$HouseNum<-factor(M$HouseNum, labels= c("1","2","3","4","5","6","7","8","10"))
  17. M$HouseInhabitantsNum<-NULL #factor(M$HouseInhabitantsNum, labels= c("1","2","3","4","5"))
  18. M$AvgAge<-factor(M$AvgAge, labels = c("20-30","30-40","40-50","50-60","60-70","70-80"))
  19. M$ClientType<-factor(M$ClientType, labels = c("Successful hedonists", "Driven Growers","Average Family","Career Loners","Living well","Cruising Seniors","Retired and Religeous","Family with grown ups","Conservative families","Farmers"))
  20. M$Religion<-factor(M$Religion, labels = c("Catholic","Protestant","Other","No religion"))
  21. M$CivilState<-factor(M$CivilState, labels = c("Married", "cohabitation", "Others"))
  22. M$FamilyType<-factor(M$FamilyType, labels = c("Single", "Family without children", "Family with children"))
  23. M$ScholarEducation<-NULL #factor(M$ScholarEducation, labels = c("High", "Mid", "Low"))
  24. M$JobType<-factor(M$JobType, labels = c("High position", "Enterprising", "Farmer","Middle management", "Qualified worker", "Unqualified worker"))
  25. M$SocialClass<-factor(M$SocialClass, labels = c("A", "B1", "B2", "C", "D"))
  26. M$HouseType<-factor(M$HouseType, labels = c("Tenant", "Owner"))
  27. M$CarsNum<-factor(M$CarsNum, labels = c("One", "Two", "No car"))
  28. M$HealthType<-factor(M$HealthType, labels = c("Fonasa", "Isapre"))
  29. M$AvgIncome<-factor(M$AvgIncome, labels = c("Low", "Mid Low", "Medium", "Mid High", "High"))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top