Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
600
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. > library(factoextra)
  2. Loading required package: ggplot2
  3. > library(cluster)
  4. > data <- read.csv(file.choose())
  5. > head(data)
  6. Email Behavior.3 Brand.Preference CTA Demo.Age
  7. 1 nisl@adipiscingelit.org 16 12 9 48
  8. 2 dui.Fusce.diam@non.edu 25 8 6 41
  9. 3 nisl.Maecenas@vitaeorciPhasellus.org 23 11 4 50
  10. 4 justo.nec@Aenean.edu 4 12 11 34
  11. 5 neque.Morbi.quis@AeneanmassaInteger.ca 29 10 2 59
  12. 6 elit@erat.org 16 6 13 57
  13. > #give variables equal weight and remove E-mail column
  14. > standardized <- scale(data[-1])
  15. > head(standardized)
  16. Behavior.3 Brand.Preference CTA Demo.Age
  17. [1,] -0.06450461 1.5764994 -0.06016808 0.4519195
  18. [2,] 1.01724970 0.4409656 -0.65523704 0.0209336
  19. [3,] 0.77685986 1.2926159 -1.05194967 0.5750583
  20. [4,] -1.50684369 1.5764994 0.33654455 -0.4100523
  21. [5,] 1.49802940 1.0087325 -1.44866231 1.1291831
  22. [6,] -0.06450461 -0.1268013 0.73325719 1.0060442
  23. > #Elbow and Silhouette to select the best K
  24. > fviz_nbclust(standardized, kmeans, method = "wss")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement