title: hierarchical clustering with gower distance - hclust() and philentropy::distance()
body: <p>I've got a mixed data set (categorical and continuous variables) and I'd like to do <strong>hierarchical clustering</strong> using Gower distance.</p>
  
  <p>I base my code on an example from <a href="https://www.r-bloggers.com/hierarchical-clustering-in-r-2/" rel="nofollow noreferrer">https://www.r-bloggers.com/hierarchical-clustering-in-r-2/</a>, which uses base R <code>dist()</code> for Euclidean distance. Since <code>dist()</code> doesn't compute Gower distance, I've tried using <code>philentropy::distance()</code> to compute it but it doesn't work. </p>
  
  <p>Thanks for any help!   </p>
  
  <pre><code># Data
  data("mtcars")
  mtcars$cyl &lt;- as.factor(mtcars$cyl)
  
  # Hierarchical clustering with Euclidean distance - works 
  clusters &lt;- hclust(dist(mtcars[, 1:2]))
  plot(clusters)
  
  # Hierarchical clustering with Gower distance - doesn't work
  library(philentropy)
  clusters &lt;- hclust(distance(mtcars[, 1:2], method = "gower"))
  plot(clusters)
  </code></pre>