Error in using HCLUST

HI - I'm getting an error while running the HCLUST code below ... ALso - My distance matrix is big ... (Attached for reference)

Calculations ;

csim <- csim %*% t(csim)
cdist <- as.dist(1 - csim)
hc <- hclust(cdist, "ward.D")

Error : Error in hclust(cdist, "ward.D") : NA/NaN/Inf in foreign function call (arg 11)

Please suggest.

Parvati Patnaik

Welcome to the community, Parvati!

You forgot to attach the distance matrix. So, I can only guess that some elements of it are missing or infinite. Can you please check that? Try with sum(is.infinite(x = cdist)), sum( = cdist)) and sum(is.nan(x = cdist)).

If that doesn't solve your problem, can you please provide a REPRoducible EXample of your problem? It provides more specifics of your problem, and it helps others to understand what problem you are facing.

In case you don't know how to make a reprex, here's a great link:

Also, please share a small part of the dataset in a copy-paste friendly format.

The dput function is very handy, if you have stored the dataset in some R object.

In case you've your dataset on a spreadsheet, check out the datapasta package. Take a look at the following link:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.