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