checkGroups function

Helper function to check groups in data.