library(cluster)
# The Ruspini data set from the package "cluster""
x = as.matrix(ruspini)
# assign random weights to observations
w = sample(1:10,nrow(x),replace = TRUE)
# assign random clusters to observations
cl = sample(1:3,nrow(x),replace = TRUE)
#output distances between clusters based on Ward's method under the random cluster assignments
distw(x, cl, w)
Run the code above in your browser using DataLab