This is the data I got, but I could change the "a" to a number as well if that makes things easier.
Using your code gives me the following error
no applicable method for 'group_by_' applied to an object of class "c('SpatialPolygonsDataFrame', 'SpatialPolygons', 'Spatial', 'SpatialVector', 'SpatialPolygonsNULL')"