Mean per group and with count of variables in group [duplicate]
问题 This question already has answers here : How to use dplyr as alternative to aggregate (2 answers) Count number of rows within each group (15 answers) Closed 1 year ago . I would like to generate a table with groups per range, the mean and the count of variables in each group. I have a data.frame like below: Variable Shap 1 0.10 6 0.50 7 0.30 5 0.40 9 0.10 9 0.25 2 0.24 9 0.23 5 0.22 5 0.21 1 0.20 4 0.19 5 0.18 8 0.17 6 0.16 And would like to get a dataframe like this Range Shap_Avg Counts 0-5