Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of Gower distances #8

Open
kurpav00 opened this issue Aug 24, 2022 · 0 comments
Open

Use of Gower distances #8

kurpav00 opened this issue Aug 24, 2022 · 0 comments

Comments

@kurpav00
Copy link

Hello,

Would it be possible to modify the shc function to also handle Gower distances? Currently, shc only accepts numeric matrices, but Gower distances are calculated from a data frame with mixed column types, which is currently not possible as an input to shc. To illustrate:

> frame <- data.frame(var1=c(1,2,3,4,5,6),var2=c(0.1,0.2,0.3,0.4,0.5,0.6),var3=c("a","a","a","b","b","b"))
> frame$var3 <- as.factor(frame$var3)
> shc(frame,n_min = 3)
Error in shc(frame, n_min = 3) : 
  x must be a matrix; use as.matrix if necessary
> shc(as.matrix(frame),n_min = 3)
Error in colMeans(x) : 'x' must be numeric
In addition: Warning message:
In dist(x, method = metric, p = l) : NAs introduced by coercion
> shc(as.matrix(frame),n_min = 3,matmet = function(x){cluster::daisy(x,metric = "gower")})
 Error in cluster::daisy(x, metric = "gower") : 
x is not a dataframe or a numeric matrix. 

Thank you in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant