The example that you give is for plotting maps, usually starting from a shapefile. In that case the data contains a column named group
which is used by geom_polygon
to ensure that boundaries and shapes are connected correctly. If the column were named something else, e.g. xxx
, then you’d use group = xxx
.
This question and answer demonstrate what happens when grouping is incorrect.
solved Why do we use group = group in ggplot2 plots in R?