https://www.rstudiodatalab.com/2023/08/generate-aggregate-count-attach-change.html