kmeans complains “NA/NaN/Inf in foreign function call (arg 1)”, when there are none?

The key is to convert the column with the desired labels to row names with

df <- tibble::column_to_rownames(df, var = "labels")

That way the clustering algorithm won’t even consider the labels, but will apply them to the points on the cluster.

Leave a Comment