April 2017
Beginner to intermediate
420 pages
9h 58m
English
To begin this step, we will need to wrangle our data a little bit. As this method can take variables that are factors, we will convert alcohol to either high or low content. It also takes only one line of code utilizing the ifelse() function to change the variable to a factor. What this will accomplish is if alcohol is greater than zero, it will be High, otherwise, it will be Low:
> wine$Alcohol <- as.factor(ifelse(df$Alcohol > 0, "High", "Low"))
We are now ready to create the dissimilarity matrix using the daisy() function from the cluster package and specifying the method as gower:
> disMatrix <- daisy(wine[, -1], metric = "gower")
The creation of the cluster object--let's call it pamFit--is done with the pam() function, ...
Read now
Unlock full access