This works:
HDMD::pairwise.mahalanobis(x=iris[,1:4], grouping=iris$Species)
x
should be a numeric matrix of observations (columns=variables, rows=observations)
grouping
should be a "vector of characters or values designating group classification for observations" with length equal to nrow(x)
I realized in editing your question that the problem stems from a typo (you assigned varibles
instead of variables
); if you fix that typo, your code seems to work (at least doesn't throw an error). (I still claim that my solution is simpler ...)
if you wanted to be a little more careful you could use x <- iris[colnames(x) != "Species"]
(or a subset(select=)
or dplyr::select()
analog) to refer to the omitted column by name rather than position.
If you want (for some reason) to run this analysis with a single response variable, you need to use drop=FALSE
to prevent a one-column matrix from being collapsed to a vector, i.e. use x=iris[,1,drop=FALSE]