External Cluster Validation - Categorical Data

Using a reprex (see the FAQ) helps catch errors such as this one— should be mushrooms$class. With that correction

class <- as.numeric(mushrooms$class) 
#> Warning: NAs introduced by coercion
which(isTRUE(class))
#> integer(0)

In other words, the class argument is empty and dist() has nothing to work with.