Edit: The minDiff
package has been superceded by the anticlust
package.
This is a very late answer, but I found this page while googling whether
the problem as stated has ever been discussed anywhere. Maybe my answer
will help if someone finds this page from now on.
I wrote an R package, which does exactly what the question
asked for: it takes a data.frame
and creates N different groups while
trying to minimize the differences between groups in one or several
criteria. It uses a simple method based on repeated random
assignment, which is also the suggested method in the approved response.
This is the link to the package minDiff:
To tackle the stated problem, you could use:
library(minDiff)
assigment <- create_groups(dataframe, criteria_scale = c("price", "click count", "rating"), sets_n = N, repetitions = 1000)
The repetitions
argument will determine how often you randomly create
different groups. The best assignment - the one that has minimal
differences between groups - will be returned.