R: add groups() function

Creates list of groups/clusters/communities.