tidymodels / tidyclust

A tidy unified interface to clustering models
https://tidyclust.tidymodels.org/
Other
109 stars 17 forks source link

produce informative error if neither `num_clust` or `cut_height` is specified #147

Closed EmilHvitfeldt closed 1 year ago

EmilHvitfeldt commented 1 year ago

To close https://github.com/tidymodels/tidyclust/issues/98

This change is especially needed as the old errors refers to k and h as arguments, but they don't work in {tidyclust}.

Current:

library(tidyclust)

hclust_spec <- hier_clust()

hclust_fit <- fit(hclust_spec, ~., mtcars)

hclust_fit %>%
  extract_cluster_assignment()
#> Error in stats::cutree(object, k = num_clusters, h = cut_height): either 'k' or 'h' must be specified

This PR:

library(tidyclust)

hclust_spec <- hier_clust()

hclust_fit <- fit(hclust_spec, ~., mtcars)

hclust_fit %>%
  extract_cluster_assignment()
#> Error in `extract_cluster_assignment()`:
#> ! Please specify either `num_clusters` or `cut_height`.
github-actions[bot] commented 1 year ago

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.