getGroups function

Determine groups and group means