For the iris
data set, I am trying to find the Mahalanobis distances between each pair of species. I have tried the following but have had no luck. I tried the following:
group <- matrix(iris$Species)
group <- t(group[,-5])
variables <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width")
varibles <- as.matrix(iris[,variables])
mahala_sq <- pairwise.mahalanobis(x=variables, grouping=group)
But get the error message
Error in pairwise.mahalanobis(x = variables, grouping = group) : nrow(x) and length(grouping) are different
pairwise.mahalanobis
is from ... – Ben Bolker