from my previous question Updating a custom function to get combined summary statistics by groups
I am trying to update this function like where I want N (number of r